motiondivision / motion

A modern animation library for React and JavaScript
https://motion.dev
MIT License
25.84k stars 849 forks source link

onAnimationStartWithDelay #2765

Open saiichihashimoto opened 3 months ago

saiichihashimoto commented 3 months ago

Is your feature request related to a problem? Please describe. Sometimes, I want to use onAnimationStart for when the animation actually starts, including it's delay (including if it's a staggered child of it's parent, etc). Truly when it starts. Currently, onAnimationStart is mostly a wrapper around useContext(MotionContext).animate

Describe the solution you'd like A callback for when an animation has actually begun in the DOM.

Describe alternatives you've considered Currently, I'm wrapping motion.div in my own component that uses a setTimeout based on the animate and variants[definition].transition.delay it's given in props and hoping they correlate.

leosantacruz commented 1 month ago

That will definitely be very useful. In fact, I would suggest that the onAnimationStart method should detect when the motion element has the delay prop. That's the actual moment when the animation should start.