4.5.8. Playing an animation
-
-
Assert that at least one of animation’s start time or hold time is resolved.
-
Let ready time be the time value of the timeline associated with animation at the moment when animation became ready.
-
Perform the steps corresponding to the first matching condition below, if any:
- If animation’s hold time is resolved,
-
-
Apply any pending playback rate on animation.
-
Let new start time be the result of evaluating
ready time − hold time / playback ratefor animation. If the playback rate is zero, let new start time be simply ready time. -
Set the start time of animation to new start time.
-
If animation’s playback rate is not 0, make animation’s hold time unresolved.
-
- If animation’s start time is resolved and animation has a pending playback rate,
-
-
Let current time to match be the result of evaluating
(ready time − start time) × playback ratefor animation. -
Apply any pending playback rate on animation.
-
If animation’s playback rate is zero, let animation’s hold time be current time to match.
-
Let new start time be the result of evaluating
ready time − current time to match / playback ratefor animation. If the playback rate is zero, let new start time be simply ready time. -
Set the start time of animation to new start time.
-
-
Resolve animation’s current ready promise with animation.
-
Run the procedure to update an animation’s finished state for animation with the did seek flag set to false, and the synchronously notify flag set to false.
Note: The order of the above two steps is important since it means that an animation with zero-length associated effect will resolve its current ready promise before its current finished promise.
If a user agent determines that animation is immediately ready, it may schedule the above task as a microtask such that it runs at the next microtask checkpoint, but it must not perform the task synchronously.
-