Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Commits on Aug 11, 2023

  1. Add queue for animation when visualEl is deferred

    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.
    Gritsch Markus committed Aug 11, 2023
    Configuration menu
    Copy the full SHA
    c867add View commit details
    Browse the repository at this point in the history