Search

Back

Copy Link

Library

/

Free

/

34

Swipe Down

34

Swipe Down

Not loading? Preview

Made by

@frameroverrides

override

drag

Override

Swipe Down

Copy

Override

Copied to Clipboard!

Instructions

Code Preview

import { Override } from "framer"
import { useRef, useState } from "react"

export function realisticDropEffect(): Override {
    const [isDragging, setIsDragging] = useState(false)
    const [dropY, setDropY] = useState(100)
    const [isAnimating, setIsAnimating] = useState(false)
    const ref = useRef(null)

    const handleMouseEnter = () => {
        if (!isDragging && !isAnimating) {
            setIsAnimating(true)
            setDropY(100)
        }
    }

    const handleAnimationEnd = () => {
        setIsAnimating(false)
    }

    const handleMouseDown = (event) => {
        setIsDragging(true)
        event.target.setPointerCapture(event.pointerId)
    }

    const handleMouseMove = (event) => {
        if (isDragging) {
            setDropY(event.clientY)
        }
    }

    const handleMouseUp = () => {
        setIsDragging(false)
        setDropY(100)
    }

    const handleMouseLeave = () => {
        setIsDragging(false)
        setDropY(100)
    }

    return {
        ref,
        style: {
            top: dropY,
            position: "absolute",
            transition: isDragging
                ? "none"
                : isAnimating
                ? "top 0.8s cubic-bezier(0.3, 2.4, 0.85, 2.5)"
                : "none",
        },
        onMouseEnter: handleMouseEnter,
        onMouseDown: handleMouseDown,
        onMouseMove: handleMouseMove,
        onMouseUp: handleMouseUp,
        onMouseLeave: handleMouseLeave,
        onAnimationComplete: handleAnimationEnd,
    }
}

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.