Window: animationstart event
The animationstart event is fired when a CSS Animation has started. If there is an animation-delay, this event will fire once the delay period has expired. A negative delay will cause the event to fire with an elapsedTime equal to the absolute value of the delay (and, correspondingly, the animation will begin playing at that time index into the sequence).
| Bubbles | Yes |
|---|---|
| Cancelable | No |
| Interface | AnimationEvent |
| Event handler property | onanimationstart |
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: animationstart.
Examples
This listens for the animationstart event and logs a message when it is fired:
window.addEventListener('animationstart', () => { console.log('Animation started'); });
The same, but using onanimationstart:
window.onanimationstart = () => { console.log('Animation started'); };
See a live example of this event.
Specifications
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
animationstart_event |
43
1
|
18
≤79
|
51 |
No |
? |
9 |
43
≤37
|
43
18
|
51 |
? |
9 |
4.0
1.0
|
See also
- CSS Animations
- Using CSS Animations
AnimationEvent- Related events:
animationend,animationiteration,animationcancel - This event on
Documenttargets:animationstart - This event on
HTMLElementtargets:animationstart
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Window/animationstart_event