Description
Currently the css-animations-1 AnimationEvent and the css-transitions-1 TransitionEvent only provide details about the animation (its name, and timing) or transition (property and timing), but if you wanted to get the actual Animation object you would have to call getAnimations() on the element and find the corresponding animation. E.g.
element.addEventListener('animationstart', (evt) => {
// evt does not contain the animation so we have to find it.
let animation = element.getAnimations().find(anim => anim.animationName == evt.animationName);
});
If the same animation name is started twice, e.g. animation: keyframes 1s, keyframes 1s
, the developer doesn't have any way to know which Animation object in the getAnimations list corresponds to the AnimationEvent.
I propose we add the web-animations Animation object for the animation / transition to these events so that developers can easily get the associated Animation from the events. I'd propose calling it animation
in both interfaces though we could consider calling it transition
in the TransitionEvent interface even though the type would be Animation.