Element.getAnimations()
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
getAnimations()
は Element
インターフェイスのメソッドで(Animatable
ミックスインで指定されており)、この要素に影響を与える、あるいは将来的に影響を与える予定のすべての Animation
オブジェクトの配列を返します。オプションとして、子孫要素の Animation
オブジェクトも返すことができます。
メモ: この配列には CSS アニメーション、CSS トランジション、ウェブアニメーションが含まれます。
構文
const animations = Element.getAnimations(options);
引数
options 省略可
-
以下のプロパティを含むオプションオブジェクトです。
subtree
-
論理値で、
true
の場合、 Element の子孫をターゲットとしたアニメーションも返すようになります。これは、 Element やその子孫に付けられた CSS 擬似要素をターゲットとするアニメーションを含みます。既定値はfalse
です。
返値
例
以下のコードでは、 elem
とその子孫のすべてのアニメーションが終了するのを待ってから、文書からその要素を削除します。
Promise.all(
elem.getAnimations({ subtree: true })
.map(animation => animation.finished)
).then(() => elem.remove());
仕様書
Specification |
---|
Web Animations # dom-animatable-getanimations |
ブラウザーの互換性
BCD tables only load in the browser
関連情報
- ウェブアニメーション API
- CSS アニメーション
- CSS トランジション
Document.getAnimations()
- 文書内のすべてのアニメーションを読み取るAnimation