Search

Back

Copy Link

Library

/

Free

/

36

Expand & Fade

36

Expand & Fade

FREE

Not loading? Preview

Made by

@frameroverrides

override

click

Override

Expand & Fade

Copy

Override

Copied to Clipboard!

Instructions

Code Preview

import * as React from "react"
import { Override } from "framer"
import { useAnimation, motion } from "framer-motion"

export function withClick(): Override {
    const controls = useAnimation()

    const handleClick = async () => {
        await controls.start({
            opacity: [1, 0],
            scale: [1, 1.3],
            borderWidth: ["0px", "10px"],
            borderColor: [
                "rgba(135, 135, 135, 0.17)",
                "rgba(135, 135, 135, 0.17)",
            ],
            transition: {
                duration: 0.4,
                ease: "easeOut",
            },
        })

        controls.set({
            scale: 1,
            borderWidth: "0px",
            borderColor: "transparent",
        })

        await controls.start({
            opacity: 1,
            transition: {
                duration: 0.6,
                ease: "easeInOut",
            },
        })
    }

    return {
        as: motion.div,
        style: {
            borderStyle: "solid",
            transformOrigin: "center",
        },
        initial: {
            borderWidth: "0px",
            borderColor: "transparent",
        },
        animate: controls,
        onTap: handleClick,
    }
}

export function withHover(): Override {
    const controls = useAnimation()

    const handleMouseEnter = async () => {
        await controls.start({
            opacity: [1, 0],
            scale: [1, 1.3],
            borderWidth: ["0px", "10px"],
            borderColor: [
                "rgba(135, 135, 135, 0.17)",
                "rgba(135, 135, 135, 0.17)",
            ],
            transition: {
                duration: 0.4,
                ease: "easeOut",
            },
        })

        controls.set({
            scale: 1,
            borderWidth: "0px",
            borderColor: "transparent",
        })

        await controls.start({
            opacity: 1,
            transition: {
                duration: 0.6,
                ease: "easeInOut",
            },
        })
    }

    return {
        as: motion.div,
        style: {
            borderStyle: "solid",
            transformOrigin: "center",
        },
        initial: {
            borderWidth: "0px",
            borderColor: "transparent",
        },
        animate: controls,
        onHoverStart: handleMouseEnter, // Updated here
    }
}

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.