Search

Back

Copy Link

Library

/

Free

/

37

3D Spin (X-Axis)

37

3D Spin (X-Axis)

FREE

Not loading? Preview

Made by

@frameroverrides

override

click

Override

3D Spin (X-Axis)

Copy

Override

Copied to Clipboard!

Instructions

Code Preview

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

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

        const handleClick = async (e) => {
            await controls.start({
                rotateX: [0, 360],
                transition: { duration: 0.6, ease: "easeOut" },
            })
            controls.set({ rotateX: 0 })
            if (props.onClick) {
                props.onClick(e)
            }
        }

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


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

        const handleMouseEnter = async (e) => {
            await controls.start({
                rotateX: [0, 360],
                transition: { duration: 0.6, ease: "easeOut" },
            })
            controls.set({ rotateX: 0 })
            if (props.onMouseEnter) {
                props.onMouseEnter(e)
            }
        }

        return (
            <Component
                {...props}
                as={motion.div}
                style={{
                    ...props.style,
                    transformOrigin: "center",
                }}
                onMouseEnter={handleMouseEnter}
                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.