Re: [csswg-drafts] [web-animations-1] Make animations become idle when they have an inactive timeline (#2066)

> > 1. https://drafts.csswg.org/scroll-animations-1/#current-time-algorithm - update ScrollTimeline.currentTime calculation as follows:
> >    
> >    * If current scroll offset is less than startScrollOffset, return (0 - epsilon) or -infinity.
> >    * If current scroll offset is greater than or equal to endScrollOffset, return ( effective time range + epsilon) or +infinity.
> >    * Consider: do we need explicitly address a case when startScrollOffset equals to endScrollOffset?
> 
> I want to avoid returning any epsilon values. That still leaves open the question of what is the current time of a timeline when it is in the new `BeforeStart` or `AfterEnd` states.
> 
> My intuition here is simply that it should be `0` or `effective time range` respectively. That can lead to bugs if script fails to check the timeline state, but given that it is the current time that will be used by those animations that are deemed to be active in those states, I think it's the most correct behavior.

To be clear, in the BeforeStart phase will it only be fill: backwards animations which are active or any animation which is active at time 0? Currently I think we have the latter, which leads to an asymmetric behavior with the implicit backwards fill due to 0 being an active time in the animation: https://github.com/w3c/csswg-drafts/issues/4325
 
> > ## Use Cases
> > 
> > 1. An animation that is idle until its timeline starts to play
> >    ```js
> >    scroller.style.overflow="none";
> >    scroll_timeline = new ScrollTimeline({scrollSource: scroller, ...});
> >    animation = new Animation(new KeyframeEffect(...}], { duration: 2000}), scroll_timeline);
> >    animation.play();
> >    console.log(animation.startTime); // 0
> >    console.log(animation.currentTime); // null
> >    console.log(animation.playState); // idle
> >    ```
> 
> I think it would actually be preferable if the `playState` were `'running'` here--assuming that the animation will be running once `scroller` becomes available.

I agree. IMO I think that we should preserve the playing state of animations even if the timeline is temporarily inactive (i.e. content is temporarily not scrollable and becomes scrollable again).

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

Received on Wednesday, 22 January 2020 21:19:12 UTC