Search

11. Drag: Constraints

11. Drag: Constraints

Add dragConstraints to limit how far you can drag an element.

⚡️ Some Examples – 11 – Drag: Constraints
open in CodeSandbox
export function Example() {
    return (
        <motion.div
            style={{
                width: 150,
                height: 150,
                borderRadius: 30,
                backgroundColor: "#fff",
            }}
            drag
            dragConstraints={{ top: -125, right: 125, bottom: 125, left: -125 }}
            dragTransition={{ bounceStiffness: 600, bounceDamping: 20 }}
            dragElastic={0.5}
        />
    );
}

Leave a Reply

plugins premium WordPress
Scroll to Top