Document: getAnimations() メソッド
Baseline
広く利用可能
この機能は広く実装されており、多くのバージョンの端末やブラウザーで動作します。2020年9月以降、すべてのブラウザーで利用可能です。
getAnimations() メソッドは Document インターフェイスのメソッドで、この文書の配下にあるターゲット要素にあるすべての Animation オブジェクトの配列を返します。この配列には CSS アニメーション, CSS トランジション, ウェブアニメーション が含まれます。
構文
js
getAnimations()
引数
なし。
返値
Animation オブジェクトの配列 (Array) で、それぞれの要素は呼び出された Document の配下にある要素に現在関連付けられているアニメーション 1 つを表します。
例
次のコードスニペットは、ページ上のすべてのアニメーションの Animation.playbackRate を半分にすることで速度をゆっくりにします。
js
document.getAnimations().forEach((animation) => {
animation.playbackRate *= 0.5;
});
仕様書
| 仕様書 |
|---|
| Web Animations> # dom-documentorshadowroot-getanimations> |
ブラウザーの互換性
関連情報
- ウェブアニメーション API
- CSS アニメーション
- CSS トランジション
Element.getAnimations()- 単一の要素 (Element) とその子孫にあるアニメーションのみを読み取るAnimation