Reputation: 15375
I have a fairly complex page that contains several nested layers of React components inside a Framer Motion <LayoutGroup>
, containing a large number of leaf <motion.div>
instances. What I want to do is perform some state update and then wait for all nested child animations to complete before performing another action.
Is there an easy way to do this without a ton of manual coordination? I can see that it would be possible for me to attach onAnimationStart
and onAnimationComplete
callbacks all over the place, but it seems really painful to keep track of how many animations are pending, as well as differentiating the start state (when onAnimationStart
hasn't fired yet) from the end state. Keeping track of these counts also seems like it will leak a lot of 'implementation details' of my hierarchy -- really I'd ideally like to be able to add and remove <motion.div>
from deeply nested child components without needing to go update some global animation coordinator logic.
Upvotes: 0
Views: 21