Animation: finished プロパティ
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2020年7月.
Animation.finished は ウェブアニメーション API の読み取り専用プロパティで、アニメーションの再生が完了すると解決される Promise を返します。
メモ:
アニメーションが finished の再生状態から離れる時点(つまり、再び再生を始める時点)ごとに、このプロパティに対して新しい Promise が作成されます。新しい Promise は新しいアニメーションシーケンスが完了すると解決されます。
値
アニメーションの実行が完了すると解決される Promise オブジェクト。
例
以下のコードは、要素 elem で実行するアニメーションがすべて完了するまで待ち、その要素を DOM ツリーから削除します。
js
Promise.all(elem.getAnimations().map((animation) => animation.finished)).then(
() => elem.remove(),
);
仕様書
| Specification |
|---|
| Web Animations # dom-animation-finished |
ブラウザーの互換性
Enable JavaScript to view this browser compatibility table.