このページはコミュニティーの尽力で英語から翻訳されました。MDN Web Docs コミュニティーについてもっと知り、仲間になるにはこちらから。

View in English Always switch to English

Document: getAnimations() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020年9月⁩.

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

構文

js
getAnimations()

引数

なし。

返値

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

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

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

仕様書

Specification
Web Animations
# dom-documentorshadowroot-getanimations

ブラウザーの互換性

関連情報