Animation: finished property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.
TheAnimation.finished read-only property of theWeb Animations API returns aPromise which resolves once the animation has finished playing.
Note:Every time the animation leaves thefinished play state (that is, when it starts playing again), a newPromise is created for this property. The newPromise will resolve once the new animation sequence has completed.
In this article
Value
APromise object which will resolve once the animation has finished running.
Examples
The following code waits until all animations running on the elementelem have finished, then deletes the element from the DOM tree:
js
Promise.all(elem.getAnimations().map((animation) => animation.finished)).then( () => elem.remove(),);Specifications
| Specification |
|---|
| Web Animations> # dom-animation-finished> |