Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. Element
  4. getAnimations()

Element: getAnimations() method

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⁩.

ThegetAnimations() method of theElement interface(specified on theAnimatable mixin) returns an array of allAnimation objects affecting this element or which are scheduled to do soin future. It can optionally returnAnimation objects for descendantelements too.

Note:This array includesCSS Animations,CSS Transitions, andWeb Animations.

Syntax

js
getAnimations()getAnimations(options)

Parameters

optionsOptional

An options object containing the following property:

subtree

A boolean value which, iftrue, causes animations that targetdescendants ofElement to be returned as well. This includes animationsthat target any CSSpseudo-elements attached toElement or one of its descendants. Defaults tofalse.

Return value

AnArray ofAnimation objects, each representing ananimation currently targeting theElement 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 onelem and itsdescendants to finish before removing the element from the document.

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

Specifications

Specification
Web Animations
# dom-animatable-getanimations

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp