4.5.8. Playing an animation

The procedure to , , given a flag , is as follows:
    1. Assert that at least one of animation’s start time or hold time is resolved.

    2. Let ready time be the time value of the timeline associated with animation at the moment when animation became ready.

    3. Perform the steps corresponding to the first matching condition below, if any:

      If animation’s hold time is resolved,
      1. Apply any pending playback rate on animation.

      2. Let new start time be the result of evaluating ready time − hold time / playback rate for animation. If the playback rate is zero, let new start time be simply ready time.

      3. Set the start time of animation to new start time.

      4. 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,
      1. Let current time to match be the result of evaluating (ready time − start time) × playback rate for animation.

      2. Apply any pending playback rate on animation.

      3. If animation’s playback rate is zero, let animation’s hold time be current time to match.

      4. Let new start time be the result of evaluating ready time − current time to match / playback rate for animation. If the playback rate is zero, let new start time be simply ready time.

      5. Set the start time of animation to new start time.

    4. Resolve animation’s current ready promise with animation.

    5. 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.