useAnimate | Framer for Developers
useAnimate provides a way of using the animate function that is scoped to the elements within your component. It provides a scope ref, and an animate function where every DOM selector is scoped to this ref. Additionally, when the component calling useAnimate is removed, all animations started with its returned animate function will be cleaned up automatically. Declarative animations via motion components tend to be simpler to write and maintain. However, imperative animations via useAnimate() are very powerful, allowing: Ultimately which you use depends on your needs and usecase. Import from "framer-motion". useAnimate returns two arguments, a scope ref and an animate function. This scope ref must be passed to either a regular HTML/SVG element or a motion component. This scoped animate function can now be used in effects and event handlers to animate elements. We can either use the scoped element directly: Or by passing it a selector. This selector is "li", but we're not selecting all
useAnimate provides a way of using the animate function that is scoped to the elements within your component. This allows you to use manual animation controls, timelines, selectors scoped to your component, and automatic cleanup. It provides a scope ref, and an animate function where every DOM selector is scoped to this ref. function Component () { const [ scope , animate ] = useAnimate () useEffect (() => { // This "li" selector will only select children // of the element that receives `scope`. animate ( " li " , { opacity : 1 }) }) return < ul ref = { scope } > { children } </ ul > } Additio
Explore this link on the map →related reading
- Inside Framer's Magic Motionnan.fyi
- 60fps - UI/UX animation inspiration for mobile & web apps60fps.design
- propEffect | Render motion values to object props | Motionmotion.dev
- Animated Elements | React Springreact-spring.dev
- The Web Animation Performance Tier List | Motion Magazinemotion.dev
- You Don't Need Animationsemilkowal.ski
- The Web Animation Performance Tier List | Motion Magazinemotion.dev
- The Power of Keys in Framer Motionnan.fyi
- 7 Practical Animation Tipsemilkowal.ski
- Reduce bundle size of Framer Motion | Motion for Reactmotion.dev
- Introduction - Fancy Componentsfancycomponents.dev
- Made With Gsapmadewithgsap.com