

#
“onanimationcancel”イベントハンドラ
イベント名 | “animationcancel”イベント |
インターフェース | “AnimationEvent”インターフェース |
バブリング | Yes |
キャンセル | No |
“onanimationcancel”イベントハンドラはCSSの“animation”プロパティなどによるアニメーションの再生が中止されたときに発生する“animationcancel”イベントを処理するためのイベントハンドラです。
“animationcancel”イベントは“animation-name”プロパティの値が変更されるなどしてアニメーションが最後まで再生された時に発生する“animationend”イベントが発生せずに終わる場合に発生します。
アニメーションが最後まで再生された時に発生する“animationend”イベントを処理するには“onanimationend”イベントハンドラを使用します。
“onanimationcancel”イベントハンドラはすべてのHTMLの要素でコンテント属性とIDL属性として使用できます。また、すべての“Document”オブジェクトと“Window”オブジェクトでIDL属性として使用できます。
#
サンプルコード
IDL属性
var count = 0;
document.getElementById("sampleElement").onanimationcancel = function() {
count++;
document.getElementById("counterNumber").innerHTML = count;
};

コンテント属性
<div onanimationcancel="counter();">♪</div>
<p>イベントの発生回数:<output id="counterNumber">0</output>回</p>

#
仕様書
CSS Animations Level 1
Animation Events|Event handlers on elements, Document objects, and Window objects