Skip to content

[web-animations-2] Should there be events on target elements to detect started web animations? #9011

Open
@flackr

Description

@flackr

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:

document.body.addEventListener('animationstart', (evt) => {
  console.log(evt);
});

Animations can be started before the target is attached.

let elem = document.createElement('div');
elem.animate(keyframes, options); // animation started, but elem is not attached so the above listener wouldn't see it.
document.body.appendChild(elem);

The target can be changed after the animation is started

let anim = new Animation(keyframes, options);
anim.play(); // animation started, but has no target to dispatch events to
anim.target = document.body;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions