Repository navigation
Fixes issue with restarting animations - #9190
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8419
Description
Type of Change
Why
Animations on Animated values can be stopped and restarted for any number of reasons. When this occurs, unless the Animated value is removed, it is expected that the next animation on that value will continue from where it left off. Previously, this only worked if the animation ran to completion. These changes allow restarting animations even if the animation over the value is imperatively stopped.
Resolves #8419
Resolves #9206
What
Animated Composition values cannot be queried until the animation completes (generally, 1 full frame callback after the animation is stopped). The value is also ready to be queried after a scoped batch completion event fires.
This change introduces deferred animation starts. If we attempt to start an animation on a ValueAnimatedNode where an active animation was recently (i.e., synchronously) stopped, we wait for the
Completedcallback on that animations scoped batch to fire before starting the next animation. TheCompletedcallback will fire either after the animation has run to completion or roughly one animation frame afterStopAnimationis called.Doing this ensures that animated value in the composition property set reports the correct value when computing the frames for the next animation.
Testing
Before:
React.Native.Playground.Win32.2021-11-22.14-44-58.mp4
After:
React.Native.Playground.Win32.2021-11-22.14-42-27.mp4
This change also fixes restarts for tracking animations:
React.Native.Playground.Win32.2021-12-15.21-28-46.mp4
Notice that the animations get out of sync with one another because the UI.Composition approach requires waiting for the completion callback to start any new animations on the same value node, so "restarting" the animation, or setting a new tracked to value, causes the animation to fall behind by a frame or two. This is partly the motivation for #9249.
Microsoft Reviewers: Open in CodeFlow