最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Wait for all FramerMotion LayoutGroup animations to complete - Stack Overflow

programmeradmin0浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论