Element.getAnimations()

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The getAnimations() method of the Element interface (specified on the Animatable mixin) returns an array of all Animation objects affecting this element or which are scheduled to do so in future. It can optionally return Animation objects for descendant elements too.

Note: This array includes CSS Animations, CSS Transitions, and Web Animations.

Syntax

const animations = Element.getAnimations(options);

Parameters

options Optional
An options object containing the following property:
subtree
A boolean value which, if true, causes animations that target descendants of Element to be returned as well. This includes animations that target any CSS pseudo-elements attached to Element or one of its descendents. Defaults to false.

Return value

An Array of Animation objects, each representing an animation currently targetting the Element on which this method is called, or one of its descendant elements if { subtree: true } is specified.

Examples

The following code snippet will wait for all animations on elem and its descendants to finish before removing the element from the document.

Promise.all(
  elem.getAnimations({ subtree: true })
    .map(animation => animation.finished)
).then(() => elem.remove());

Specifications

Specification Status Comment
Web Animations
The definition of 'Animatable.getAnimations()' in that specification.
Working Draft Editor's draft.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
getAnimations
Experimental
Chrome Full support 79
Disabled
Full support 79
Disabled
Disabled From version 79: this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
No support 67 — 79
Notes Disabled
Notes Does not support the subtree option.
Disabled From version 67 until version 79 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
No support 44 — 67
Notes Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Disabled From version 44 until version 67 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
No support 38 — 44
Notes Alternate Name Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 38 until version 44 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Edge Full support 79
Disabled
Full support 79
Disabled
Disabled From version 79: this feature is behind the Experimental Web Platform Features preference.
Firefox Full support 75
Full support 75
No support 63 — 75
Disabled
Disabled From version 63 until version 75 (exclusive): this feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
No support 48 — 63
Disabled
Disabled From version 48 until version 63 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
No support 40 — 48
Notes Disabled
Notes Does not support the subtree option.
Disabled From version 40 until version 48 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
No support 33 — 40
Notes Alternate Name Disabled
Notes Does not support the subtree option.
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 33 until version 40 (exclusive): this feature is behind the dom.animations-api.core.enabled preference. To change preferences in Firefox, visit about:config.
IE No support NoOpera Full support 66
Disabled
Full support 66
Disabled
Disabled From version 66: this feature is behind the Experimental Web Platform Features preference.
No support 54 — 66
Notes Disabled
Notes Does not support the subtree option.
Disabled From version 54 until version 66 (exclusive): this feature is behind the Experimental Web Platform Features preference.
No support 31 — 54
Notes Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Disabled From version 31 until version 54 (exclusive): this feature is behind the Experimental Web Platform Features preference.
No support 25 — 31
Notes Alternate Name Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 25 until version 31 (exclusive): this feature is behind the Experimental Web Platform Features preference.
Safari Partial support Partial
Notes Disabled
Partial support Partial
Notes Disabled
Notes Does not support the subtree option.
Disabled This feature is behind the Web Animations preference and the CSS Animations via Web Animations preference.
WebView Android No support NoChrome Android Full support 79
Disabled
Full support 79
Disabled
Disabled From version 79: this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
No support 67 — 79
Notes Disabled
Notes Does not support the subtree option.
Disabled From version 67 until version 79 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
No support 44 — 67
Notes Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Disabled From version 44 until version 67 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
No support 38 — 44
Notes Alternate Name Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 38 until version 44 (exclusive): this feature is behind the Experimental Web Platform Features preference. To change preferences in Chrome, visit chrome://flags.
Firefox Android Partial support Partial
Notes Disabled
Partial support Partial
Notes Disabled
Notes Does not return any animations added via CSS.
Disabled This feature is behind the dom.animations-api.getAnimations.enabled preference. To change preferences in Firefox, visit about:config.
Opera Android Partial support 48
Notes Disabled
Partial support 48
Notes Disabled
Notes Does not support the subtree option.
Disabled From version 48: this feature is behind the Experimental Web Platform Features preference.
No support 32 — 48
Notes Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Disabled From version 32 until version 48 (exclusive): this feature is behind the Experimental Web Platform Features preference.
No support 25 — 32
Notes Alternate Name Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 25 until version 32 (exclusive): this feature is behind the Experimental Web Platform Features preference.
Safari iOS Partial support Partial
Notes Disabled
Partial support Partial
Notes Disabled
Notes Does not support the subtree option.
Disabled This feature is behind the Web Animations preference and the CSS Animations via Web Animations preference.
Samsung Internet Android Partial support 9.0
Notes Disabled
Partial support 9.0
Notes Disabled
Notes Does not support the subtree option.
Disabled From version 9.0: this feature is behind the Experimental Web Platform Features preference.
No support 4.0 — 9.0
Notes Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Disabled From version 4.0 until version 9.0 (exclusive): this feature is behind the Experimental Web Platform Features preference.
No support 3.0 — 4.0
Notes Alternate Name Disabled
Notes Does not return any animations added via CSS and does not support the subtree option.
Alternate Name Uses the non-standard name: getAnimationPlayers
Disabled From version 3.0 until version 4.0 (exclusive): this feature is behind the Experimental Web Platform Features preference.

Legend

Full support  
Full support
Partial support  
Partial support
No support  
No support
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.
See implementation notes.
See implementation notes.
User must explicitly enable this feature.
User must explicitly enable this feature.
Uses a non-standard name.
Uses a non-standard name.

See also