Re: [csswg-drafts] [scroll-animations] Should animation events fire every time active range is left / reentered? (#4324)

@fantasai You're right that the backwards direction is awkward. I put together a little demo to test what events are fired for JS and CSS animations. As discussed in this issue JS animations only currently have a finish event so the start is not observable:

https://jsbin.com/xuwebet/edit?css,js,output

The CSS events fire based on phase changes outlined in [css-animations-2 4.1 Event dispatch](https://drafts.csswg.org/css-animations-2/#event-dispatch). This seems nice from a developer standpoint where it fires animationstart every time you go from outside the active interval to inside of it, and animationend everytime you leave the active interval.

Without spec changes, the behavior for JS animations is that finish fires only on moving forwards past the end scroll offset. This is because the [finish state](https://www.w3.org/TR/web-animations-1/#finished-play-state) is explicitly the time after the animation end which doesn't change when you change scrolling directions (unless we also considered a change the scroll direction a modification of the sign of the playbackRate). I would prefer we either change the event dispatch to align with the way CSS animation events fire or introduce new JS events that align with the CSS event model. @birtles WDYT? I suspect adding new events aligned with the dispatch of the CSS animation events is less risky and wouldn't be confusing.

Assuming we do fire events bidirectionally (as the CSS events currently do), the developer can use the currentTime / elapsedTime attribute of the event to determine whether it was for the forwards or backwards direction. Another thing I noticed is the elapsed time on the css-animation events is currently exposing our internal timestampas which should be CSSNumericValue instead.

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


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

Received on Wednesday, 8 March 2023 14:15:52 UTC