In JavaScript, the animationcancel event fires when a CSS Animation unexpectedly aborts — any time it stops without sending animationend (MDN). The event object is an AnimationEvent.
Register a listener with addEventListener. Check readiness and browser support before you rely on this event.
Syntax
Listen for animationcancel. Start with this line.
JavaScript
el.addEventListener("animationcancel", fn)
Call
What it does
el.addEventListener("animationcancel", fn)
Primary signature.
Built into the browser. Listen with el.addEventListener("animationcancel", …) — no import required.
Attach both listeners. Finish and abort are separate outcomes.
Finish path. Let the animation complete → only animationend.
Abort path. Hide or remove the animation → only animationcancel.
MDN rule. Unexpected abort means no animationend for that run.
Compatibility
Browser Support
Element animationcancel is a standard CSS Animations event. MDN marks it Limited availability (not Baseline) — support varies across widely used browsers.
✓ Limited availability
Element animationcancel
Fires when a CSS animation aborts without animationend — pair with animationend for full lifecycle cleanup.
VariesNot Baseline
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
Android WebViewSupported · Modern WebView
Full support
animationcancelFeature-detect
Bottom line: Always feature-detect. Prefer addEventListener. Use animationend for normal finish and animationcancel for unexpected aborts.
Frequently Asked Questions
It fires when a CSS Animation unexpectedly aborts — any time it stops without sending animationend (MDN). Common causes: changing animation-name so the animation is removed, or hiding the element (or an ancestor) with CSS such as display: none.
No. MDN does not mark it Deprecated, Experimental, or Non-standard. It is Limited availability (not Baseline) because support is missing or incomplete in some widely used browsers.
An AnimationEvent. Useful read-only properties include animationName, elapsedTime, and pseudoElement.
Prefer element.addEventListener("animationcancel", handler). You can also set onanimationcancel. Prefer addEventListener for broader reliability.
animationend fires when an animation finishes its intended run. animationcancel fires when the animation is aborted early and never reaches a normal end — then animationend does not fire for that run.
Yes in supporting browsers: setting display: none on the animating element (or a containing node that hides it) can abort the animation and fire animationcancel (MDN).