Re: [csswg-drafts] [web-animations-1][css-animations-2] Bug in handling of auto-rewind state when playing new CSS animations (#7145)

One possible snag I encountered with this is the procedure to seamlessly update the playback rate sets the _auto-rewind_ flag to false.

This somewhat contradicts the note in the spec that says:

> Note: The auto-rewind flag is provided for other specifications that build on this model but do not require the rewinding behavior, such as CSS Animations

since we are now using the flag internally.

Working this through to see if this would actually produce a change in behavior:

* Firstly, we only trigger the play procedure if the "previous play state" of the animation is running
* If the previous play state is running and the current time is unresolved then presumably this could lead to a change in behavior -- but only if updated playback rate was not zero since the condition is "If animation’s effective playback rate = 0 and animation’s current time is unresolved"

An example of where that might come about is if we have:

```js
const animation = div.animate({ transform: 'translateX(100px)' }, 1000);
animation.cancel();
animation.timeline = null;
animation.startTime = 1;
```

Here the current time is unresolved but the `playState` is running.

To be fair, this is already weird. If we were to call `animation.updatePlaybackRate(1)` at this point, nothing would change, but if we were to call `animation.updatePlaybackRate(0)`, we'd end up with a `currentTime` of 0 and an unresolved `startTime`.

With the proposed change, we'd update the `currentTime` to 0 in _both_ cases which is at least more consistent.

If we decide to follow the approach of updating CSS Animations 2, we should also change the condition:

> If animation’s effective playback rate = 0 and animation’s current time is unresolved,

to:

> If animation’s effective playback rate = 0, and the auto-rewind flag is false, and animation’s current time is unresolved,

to make it more consistent with the other branches (and we could hoist the check for the auto-rewind flag to the parent condition).

-- 
GitHub Notification of comment by birtles
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7145#issuecomment-1069913261 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Thursday, 17 March 2022 02:31:53 UTC