Animation: finished プロパティ

Baseline 2022

Newly available

Since September 2022, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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

ブラウザーの互換性

BCD tables only load in the browser

関連情報