New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add queue for animation when visualEl is deferred #2293
base: main
Are you sure you want to change the base?
Conversation
What's changed? This pull request introduces changes to the animationControls function to handle scenarios where the visualElement might not immediately subscribe, especially in the context of the LazyMotion component. Introduced Start Queue: An array that temporarily holds animation start calls. This ensures animations are deferred until their respective visual elements have subscribed to the animation controller. Flush Mechanism: Once a visualElement subscribes, any queued animations are immediately processed and played. Error Handling: Added robust error handling to cater to potential issues during the animation process. This ensures promises are either resolved upon successful completion or rejected in case of errors. Benefits: This change ensures animations are consistently played in scenarios involving delayed visualElement subscriptions, enhancing user experience and ensuring predictable behavior. How to test: Integrate the LazyMotion component, described in framer#2292 - Integrate the LazyMotion component into a project. - Import features dynamically to keep bundle size small. - Use m-Components. - Call controls.start() before the visualElement has subscribed - in the effect. Ensure that animations play consistently, irrespective of when the controls.start() is called in relation to the visualElement subscription.
We actually used to have something like this in My concern with this, it might work ok in instances where the features are expected to arrive shortly after we trigger the animations but conceivably they could load a long time after animations are triggered at which point, are the animations still relevant? Would it be better to instantly finish animations until this? I'm not sure. |
This is what you mentioned, right fc2dda0 The key difference from the previous implementation, see the commit mentioned and the current PR, is that framer-motion subscribe triggers the start of queued animations, not a react lifecycle hook. New implementation
Difference to the previous behavior
About your questions So my answer might be: Are the animations still relevant? Thx! |
@mattgperry Maybe you can find a bit of time to think about the provided concept again? Would be awesome if this or something similar could land somehow. Thx! |
What's changed?
This pull request introduces changes to the animationControls function to handle scenarios where the visualElement might not immediately subscribe, especially in the context of the LazyMotion component.
Introduced Start Queue: An array that temporarily holds animation start calls. This ensures animations are deferred until their respective visual elements have subscribed to the animation controller.
Flush Mechanism: Once a visualElement subscribes, any queued animations are immediately processed and played.
Error Handling: Added robust error handling to cater to potential issues during the animation process. This ensures promises are either resolved upon successful completion or rejected in case of errors.
Benefits:
This change ensures animations are consistently played in scenarios involving delayed visualElement subscriptions, enhancing user experience and ensuring predictable behavior.
How to test:
Integrate the LazyMotion component, described in #2292
Ensure that animations play consistently, irrespective of when the controls.start() is called in relation to the visualElement subscription.
Fixes #2292