Document: animationiteration event

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 Document 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;

document.addEventListener('animationiteration', () => {
  iterationCount++;
  console.log(`Animation iteration count: ${iterationCount}`);
});

The same, but using the onanimationiteration event handler property:

let iterationCount = 0;

document.onanimationiteration = () => {
  iterationCount++;
  console.log(`Animation iteration count: ${iterationCount}`);
};

See a live example of this event.

Specifications

Specification Status Comment
CSS Animations Working Draft Initial definition

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
animationiteration eventChrome Full support 43Edge Full support 12Firefox Full support 51IE Full support 10Opera Full support 30Safari Full support 9WebView Android Full support 43Chrome Android Full support 43Firefox Android Full support 51Opera Android Full support 30Safari iOS Full support 9Samsung Internet Android Full support 4.0

Legend

Full support
Full support

See also