Window: animationiteration event - Web APIs 编辑
The animationiteration
event is fired when an iteration of a CSS Animation ends, and another one begins. This event does not occur at the same time as the animationend
event, and therefore does not occur for animations with an animation-iteration-count
of one.
Bubbles | Yes |
---|---|
Cancelable | No |
Interface | AnimationEvent |
Event handler property | onanimationiteration |
The original target for this event is the Element
that had the animation applied. You can listen for this event on the Window
interface to handle it in the capture or bubbling phases. For full details on this event please see the page on HTMLElement: animationiteration.
Examples
This code uses animationiteration
to keep track of the number of iterations an animation has completed:
let iterationCount = 0;
window.addEventListener('animationiteration', () => {
iterationCount++;
console.log(`Animation iteration count: ${iterationCount}`);
});
The same, but using the onanimationiteration
event handler property:
let iterationCount = 0;
window.onanimationiteration = () => {
iterationCount++;
console.log(`Animation iteration count: ${iterationCount}`);
};
See a live example of this event.
Specifications
Specification | Status | Comment |
---|---|---|
CSS Animations Level 1 | Working Draft | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
- CSS Animations
- Using CSS Animations
AnimationEvent
- Related events:
animationstart
,animationend
,animationcancel
- This event on
Document
targets:animationiteration
- This event on
HTMLElement
targets:animationiteration
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论