--- title: 'Document: animationiteration イベント' slug: Web/API/Document/animationiteration_event tags: - Animation - AnimationEvent - CSS Animations - CSS アニメーション - Event - Reference - animationiteration - イベント translation_of: Web/API/Document/animationiteration_event ---
animationiteration イベントは、 CSS アニメーションの反復が1回分終了し、次の回が始まったときに発生します。このイベントは {{domxref("Document/animationend_event", "animationend")}} イベントと同時には発生せず、従って animation-iteration-count が1のアニメーションでは発生しません。
| バブリング | あり |
|---|---|
| キャンセル | 不可 |
| インターフェイス | {{domxref("AnimationEvent")}} |
| イベントハンドラープロパティ | {{domxref("GlobalEventHandlers/onanimationiteration","onanimationiteration")}} |
このイベントの本来の対象は、トランジションが適用された {{domxref("Element")}} です。このイベントを {{domxref("Document")}} インターフェイス上で待ち受けし、キャプチャやバブリングの局面で処理することができます。このイベントについて完全な詳細は、 HTMLElement: animationiteration イベントを参照してください。
このコードは animationiteration を使用して、アニメーションの反復が終了した回数を追跡します。
let iterationCount = 0;
document.addEventListener('animationiteration', () => {
iterationCount++;
console.log(`アニメーション反復回数: ${iterationCount}`);
});
同様に、 onanimationiteration イベントハンドラープロパティを使用するとこうなります。
let iterationCount = 0;
document.onanimationiteration = () => {
iterationCount++;
console.log(`アニメーション反復回数: ${iterationCount}`);
};
| 仕様書 | 状態 | 備考 |
|---|---|---|
| {{SpecName("CSS3 Animations", "#eventdef-animationevent-animationiteration")}} | {{Spec2("CSS3 Animations")}} | 初回定義 |
{{Compat("api.Document.animationiteration_event")}}