Search

Back

Copy Link

Library

/

Free

/

84

3D Hop

84

3D Hop

Not loading? Preview

Made by

@frameroverrides

override

none

Override

3D Hop

Copy

Override

Copied to Clipboard!

Instructions

In line 9 of the code you can chance the max height for the float.

The other values shouldn’t be changed or it will alter the timing functions and be out of sync.

Code Preview

import { motion, useAnimation } from "framer-motion"
import React, { useEffect } from "react"
import type { ComponentType } from "react"

export function withFloatingAndRotating(Component): ComponentType {
    return (props) => {
        const controls = useAnimation()

        const maxHeight = -42 // max height
        // don't change these values below
        const pauseDuration = props.pauseDuration || 2
        const startDelay = props.startDelay || 0
        const spinStartDelay = props.spinStartDelay || 1

        const startAnimations = () => {
            controls.start({
                y: [0, maxHeight, 0],
                transition: {
                    duration: 3,
                    times: [0, 0.5, 1],
                    ease: "easeInOut",
                    repeat: Infinity,
                },
            })

            setTimeout(() => {
                controls.start({
                    rotateY: 360,
                    transition: {
                        duration: 1,
                        repeat: Infinity,
                        repeatDelay: pauseDuration,
                        ease: "easeInOut",
                    },
                })
            }, spinStartDelay * 1000)
        }

        useEffect(() => {
            const timeoutId = setTimeout(startAnimations, startDelay * 1000)

            return () => clearTimeout(timeoutId)
        }, [controls, startDelay, spinStartDelay])

        return (
            <Component
                {...props}
                as={motion.div}
                style={{
                    ...props.style,
                    transformOrigin: "center",
                }}
                animate={controls}
            />
        )
    }
}

Terms of Use for Free Assets

By accessing and using this Framer Override Library, you agree to the following terms:

All code snippets provided are available for your personal and professional use. This includes personal websites, client projects, and other website projects in Framer. You are strictly prohibited from sharing, redistributing, selling these code snippets, or creating derivative works for resale or distribution. Unauthorized sharing, distribution, or selling of these code snippets is a breach of these terms and may result in termination of your access to this library, along with potential legal action.