Skip to content

Fixes issue with restarting animations - #9190

Merged
Nick Gerleman (NickGerleman) merged 13 commits into
microsoft:mainfrom
rozele:issue8419
Jan 10, 2022
Merged

Nick Gerleman (NickGerleman) merged 13 commits into
microsoft:mainfrom
rozele:issue8419

Conversation

@rozele

@rozele Eric Rozell (rozele) commented Nov 22, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #8419

Description

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

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 Completed callback on that animations scoped batch to fire before starting the next animation. The Completed callback will fire either after the animation has run to completion or roughly one animation frame after StopAnimation is 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

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tracking animation nodes do not restart correctly Native animation gets "stuck" when restarting animation before previous animation completes

3 participants