Re: [csswg-drafts] [web-animations-1] animation start and iteration events (#4461)

Good question. The important difference with Web Animations is the distinction between _animation_ and _effect_.

Animations just provide play control. They don't have a concept of delays or iterations per se. Hence, the events on Animations just relate to play control: finishing and canceling (and replacing).

If we were to add iteration events they would most naturally become a property of the _effects_ instead which is where the iterations, delay, etc. are defined. This would allow, for example, listening only to events on the particular part of a scene you were interested in when group effects are used.

Initially these events were not added because of performance concerns and complications that group effects might introduce. In particular we were concerned about situations such as when a parent group applies a spring/bounce effect that causes a child effect to rapidly oscillate between being active and inactive and dispatching a large number of events as a result.

However, since then we've taken [a different approach to the requirements for dispatching events for CSS animations](https://drafts.csswg.org/css-animations-2/#event-dispatch) that limits events to 1~2 per animation frame. I think that would address some of the performance concerns we previously had but it would still require some thought (e.g. if a child group was entirely skipped over due to a low frame rate, do we dispatch a start and finish for all of its descendants, even if that child's parent is going to run another iteration? Presumably we do but there might be situations where it is less clear.).

For CSS Animations, which are implemented using in Web Animations using a special animation subclass, `CSSAnimation`, we fire events based on the state of the applied effect (i.e. the root-most effect in a group effect scenario). If we were to add events to effects, it _might_ be convenient to mirror the events of the root-most effect on the animation too but I'm not sure.

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

Received on Monday, 28 October 2019 23:12:41 UTC