Re: [csswg-drafts] [web-animations-2] [scroll-animations] should calling `play()` reset the start time of a scroll-driven animation? (#11469)

The Blink implementation for playing-an-animation has deviated significantly from what is currently in the web-animations-2 spec. Not sure how updating the spec got overlooked (not seeing a correction in scroll-animations-1 either).  The specced version does not accommodate view-timelines as we simply don't know what start time to use until layout and we know the start and end of the active range.  To start, I can summarize the revised algorithm in Blink with an explanation of the rationale here, and then we can look into updating the spec:

1. Let aborted pause be a boolean flag that is true if animation has a pending pause task, and false otherwise.
2. Let has pending ready promise be a boolean flag that is initially false.
3. Let has finite timeline be true if animation has an associated timeline that is not monotonically increasing.
4. Let enable seek be true if auto-rewind is set and finite timeline is not set.
5. Let seek time be a time value that is initially unresolved.
6. Let previous current time be the animation’s current time
7. If reset current time on resume is set:
        * Set previous current time to unresolved.
        * Set the reset current time on resume flag to false.
8. Perform the steps corresponding to the first matching condition from the following, if any:
       * If animation’s effective playback rate > 0, the enable seek flag is true and either animation’s:
           * previous current time is unresolved, or
           * previous current time < zero, or
           * previous current time ≥ associated effect end,
         Set seek time to zero.
       * If animation’s effective playback rate < 0, the enable seek flag is true and either animation’s:
           * previous current time is unresolved, or
           * previous current time ≤ zero, or
           * previous current time > associated effect end,
         If associated effect end is positive infinity,
           throw an "InvalidStateError" DOMException and abort these steps.
         Otherwise,
           Set seek time to animation’s associated effect end.
       * If animation’s effective playback rate = 0 and animation’s current time is unresolved,
           Set seek time to zero.
9. If has finite timeline and auto rewind is enabled
    * reset the flag for auto-aligned start time
    * set hold time = previous current time
10. If seek time is resolved
        set hold time = seek time
11. If hold time is resolved
...

Rest of steps are in alignment with spec.

Recap of what has changed in Blink:
* Don't set start time when using a finite timeline since we don't necessarily know that the start time is. Calculation of the deferred start time should be covered in scroll-animations-1. 
* Restrict rewinding to the start or end of the animation to time based animations.
* Checks with "auto rewind enabled" changed to "seek enabled" which has added constraint of being a monotonic timeline.
* Resets a sticky start time playing with a finite timeline and auto-rewind enabled.



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


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

Received on Tuesday, 4 February 2025 19:26:56 UTC