DOM

HTMLElement:animationiteration イベント

 編集:2022.10.03 by T.A.

[Edge]?。→

要素でアニメーションが 1 回分完了したときに発行されます。→Document:animationstartElement:animationstart

バブリング
キャンセル可能
インターフェイス
イベント ハンドラー プロパティ
スクリプトでアニメーション

HTML:

<DIV id=IdTest style="width:1em;">■</DIV>
<BUTTON id=IdPlay>再生</BUTTON>
<SPAN id=IdLog></SPAN>

JavaScript:

function Job(eve){ //animationiteration イベントの処理:
  D=eve; //
  IdLog.innerHTML=IdLog.innerHTML+"●"; //表示。
}
IdTest.onanimationiteration=Job; //イベントの割り当て。

let KF=[
  { // from
    opacity:0,
    transform:'translateX(0px)'
  },
  { // to
    opacity:1,
    transform:'translateX(100px)'
  }
];	//キーフレーム:透明→不透明で横に100px移動。
let Op={
  duration:2000 //,
//  iterations: Infinity
};	//オプション:掛かる時間2秒、繰り返し無限大。
A=IdTest.animate(KF, Op); //アニメーション開始。
IdPlay.onclick=function(){ //[再生]ボタンにclickイベント割り当て。
  A.play();  //アニメーションの再生。
}

¶アニメーションが終了しても繰り返しになっても、イベントが起こらない。

Element.animate()


テスト