Search

Back

Copy Link

Library

/

Free

/

81

Swirl

81

Swirl

Not loading? Preview

Made by

@frameroverrides

override

hover

Override

Swirl

Copy

Override

Copied to Clipboard!

Instructions

This code works by making your frame rotate by a set value on hover

  1. Place the frame I want to rotate inside of my button

  2. Set to absolute position

  3. Remove Z-index and position below text

  4. Under “style” off pointer events and user select on the text

Code Preview

import type { ComponentType } from "react"
import { useState } from "react"
import { motion } from "framer-motion"

export const withFixedRotation = (Component: ComponentType): ComponentType => {
    const rotationAngle = 180 // This is the constant for the rotation angle
    const speed = 0.3 // This is the constant for the animation speed

    return (props) => {
        const [angle, setAngle] = useState(0)

        return (
            <motion.div
                {...props}
                animate={{
                    rotate: angle,
                    transition: { ease: "easeOut", duration: speed },
                }}
                onMouseEnter={() =>
                    setAngle((prevAngle) => prevAngle + rotationAngle)
                }
            >
                <Component {...props} />
            </motion.div>
        )
    }
}

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.