Document.getAnimations()

Baseline 2022

Newly available

Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。

getAnimations() メソッドは Document インターフェイスのメソッドで、この文書の配下にあるターゲット要素にあるすべての Animation オブジェクトの配列を返します。この配列には CSS アニメーション, CSS トランジション, ウェブアニメーション が含まれます。

構文

var allAnimations = Document.getAnimations();

引数

なし。

返値

Animation オブジェクトの Array で、それぞれの要素は呼び出された Document の配下にある要素に現在関連付けられているアニメーション 1 つを表します。

次のコードスニペットは、ページ上のすべてのアニメーションの Animation.playbackRate を半分にすることで速度をゆっくりにします。

js
document.getAnimations().forEach(function (animation) {
  animation.playbackRate *= 0.5;
});

仕様書

Specification
Web Animations
# dom-documentorshadowroot-getanimations

ブラウザーの互換性

BCD tables only load in the browser

関連情報