ShadowRoot: getAnimations() メソッド

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2020.

getAnimations()ShadowRoot のメソッドで、ターゲット要素がシャドウツリーの子孫である、現在有効なすべての Animation オブジェクトの配列を返します。この配列には CSS アニメーションCSS トランジションウェブアニメーション が含まれています。

構文

js
getAnimations()

引数

なし。

返値

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

次のコードでは、シャドウツリーにあるすべてのアニメーションの Animation.playbackRate を半分にすることで、アニメーションの速度を下げます。

js
let customElem = document.querySelector("my-shadow-dom-element");
let shadow = customElem.shadowRoot;
shadow.getAnimations().forEach((animation) => {
  animation.playbackRate *= 0.5;
});

仕様書

Specification
Web Animations
# dom-documentorshadowroot-getanimations

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
getAnimations

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報