-
Notifications
You must be signed in to change notification settings - Fork 709
[web-animations-2] Should there be events on target elements to detect started web animations? #9011
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@birtles I suspect you likely have thoughts about this. |
Thanks for mentioning me. My main concern, as always, is "how does it work with groups?". I guess we'd dispatch start/end events any time a leaf For iteration events, a group effect can iterate without having a target element so we wouldn't dispatch anything in that case. As a result, if we exposed iteration events at all, there would be a difference in the events reported when the parent group iterates (no iteration events) vs when the child iterates. If we were to introduce So I think it's do-able but there might be a few oddities to think through. At a more high-level, I wonder if exposing events about effects is a good idea or not. The API currently focuses on animations as the main unit we return (specifically the One downside of reporting on effects is that they're less useful for grasping timing relationships, especially in the context of groups, but maybe there are use cases where that's fine? Another idea is an animation observer interface. Internally the Firefox DevTools uses an animation observer API modelled on the |
I've also seen this confusing developers expecting DOM events to simply trigger. It's also very important for libraries and/or large systems where events may be tracked in a generic way, separate from the mechanism that's in charge of doing the animations.
That would be great.
I'd say definitely yes. The only thing that may be interesting is perhaps on the timeline-level, but IMHO events on group animations should also cover most of these.
If I'm not mistaken, the main motivation of moving from events to observers was mostly about solving implementation issues with events. Do we have any of these here? Or is there any other benefit to moving to an observer (perf, API)? |
One of the main advantages of the observer interface is it also lets you know when animations are changed (e.g. have their playback rate updated, are paused etc.) which unlocks a few extra use cases. Sticking with events is simpler, however. |
While there are bubbling events for started css animations (e.g. animationstart) and css transitions (e.g. transitionstart) there are no events to observe when web animations have been started. An author would have to track when they start web animations internally.
Should we have events for web-animations which fire at the effect target? If so, would they be the same names / set of events as the css animation events (animationstart, animationend, animationiteration, animationcancel)?
If we do want to add these events, there are many complicated scenarios to work out, e.g. imagine the author wants to observe all animations:
Animations can be started before the target is attached.
The target can be changed after the animation is started
The text was updated successfully, but these errors were encountered: