Search

Back

Copy Link

Library

/

Free

/

21

Slide Out Right

21

Slide Out Right

Not loading? Preview

Made by

@frameroverrides

override

click

Override

Slide Out Right

Copy

Override

Copied to Clipboard!

Instructions

Place inside of a frame that has overflow set to hidden

Code Preview

import { Override, useAnimation } from "framer"
import { useCallback } from "react"

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

    const handleClick = useCallback(async () => {
        // Animate the content to the right and out of view quickly
        await animation.start({
            x: "100%",
            transition: {
                duration: 0.1,
                ease: "easeIn",
                when: "beforeChildren",
            },
        })

        // Move the content to the left (out of view) instantly
        animation.set({ x: "-100%" })

        // Animate the content from the left back to its original position with a springy stop
        animation.start({
            x: "0%",
            transition: {
                type: "spring",
                stiffness: 200,
                damping: 20,
                when: "afterChildren",
            },
        })
    }, [animation])

    return {
        animate: animation,
        onClick: handleClick,
    }
}

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

    const onMouseEnter = useCallback(async () => {
        // Animate the content to the right and out of view quickly
        await animation.start({
            x: "100%",
            transition: {
                duration: 0.1,
                ease: "easeIn",
                when: "beforeChildren",
            },
        })

        // Move the content to the left (out of view) instantly
        animation.set({ x: "-100%" })

        // Animate the content from the left back to its original position with a springy stop
        animation.start({
            x: "0%",
            transition: {
                type: "spring",
                stiffness: 200,
                damping: 20,
                when: "afterChildren",
            },
        })
    }, [animation])

    return {
        animate: animation,
        onMouseEnter: onMouseEnter,
    }
}

Previous

Next

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.