The transitioncancel event fires when a CSS transition is canceled instead of finishing with transitionend. Learn addEventListener vs ontransitioncancel, TransitionEvent properties, how it fits with transitionrun / transitionstart / transitionend, and five try-it labs.
01
Kind
Instance event
02
Type
TransitionEvent
03
When
Transition canceled
04
Handler
ontransitioncancel
05
Pair with
transitionend
06
Status
Baseline Widely
Fundamentals
Introduction
CSS transitions usually end with transitionend. Sometimes they stop early—for example you leave a :hover state before the transition finishes, or you remove the class that was driving the property change. In those cases the browser fires transitioncancel instead of transitionend.
That makes transitioncancel useful for cleanup: reset UI labels, cancel follow-up work you only wanted after a completed transition, or log that the motion did not finish normally.
💡
Beginner tip
If transitioncancel fires for a transition, transitionend will not fire for that same transition. Handle both events when you need reliable cleanup either way.
Concept
Understanding transitioncancel
An instance event on elements that participate in CSS Transitions. MDN: it fires when a CSS transition is canceled—after transitionrun and before a normal transitionend.
Cancels when the transition is interrupted in either direction mid-flight.
TransitionEvent — includes propertyName, elapsedTime, pseudoElement.
Not the normal “transition finished” signal—that is transitionend.
Baseline Widely available — solid modern browser support (since Nov 2020).
Foundation
📝 Syntax
Use the event name with addEventListener, or set the handler property:
Removing the driving class reverses or aborts the in-flight transition, so the browser fires transitioncancel instead of waiting for a normal transitionend.
Example 2 — ontransitioncancel Property
MDN’s alternate style using the event handler property.
elapsedTime is how long the transition had been running (in seconds) when cancel fired. MDN notes it is not affected by transition-delay. Multiple properties may each produce their own cancel event.
Example 4 — Cancel by Removing the Driving Class
Start a long transition with a class, then remove that class mid-flight.
Toggle the class on to start the transition; toggle it off before it finishes to see transitioncancel. Leave it on until the end to see transitionend instead. MDN’s hover demo works the same way—stop hovering early to cancel.
Applications
🚀 Common Use Cases
Cleaning up UI state when a panel closes mid-transition.
Distinguishing “finished” vs “interrupted” transition analytics.
Skipping follow-up logic that should only run after a completed motion.
Teaching the full CSS transition event set alongside transitionend.
Coordinating class toggles that both start and reverse property changes.
Under the Hood
🔧 How It Works
1
Transition is created
transitionrun fires; transitionstart follows after any delay.
Schedule
2
Something cancels it
Leave hover early, remove the driving class, or reverse the change mid-flight.
Interrupt
3
Browser fires transitioncancel
A TransitionEvent is dispatched (no matching transitionend).
Event
4
✓
Your handler cleans up
Log, reset classes, or update UI for an interrupted transition.
Important
📝 Notes
MDN: Baseline Widely available (since November 2020).
Not Deprecated, Experimental, or Non-standard — no status banner required.
If transitioncancel fires, transitionend will not fire for that transition.
Zero delay and duration means no transition events at all.
transitioncancel is marked Baseline Widely available on MDN (across browsers since November 2020). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline · Widely available
Element transitioncancel
Fires when a CSS transition is canceled; TransitionEvent exposes propertyName, elapsedTime, and pseudoElement.
FullWidely available
Google Chrome87+ (full) · earlier partial
Yes
Mozilla Firefox53+
Yes
Apple Safari13.1+
Yes
Microsoft Edge87+ Chromium
Yes
Opera73+
Yes
Internet ExplorerNo transitioncancel support
Unavailable
transitioncancelBaseline
Bottom line: Listen with addEventListener("transitioncancel", …), pair it with transitionend for cleanup, and remember cancel replaces end for that transition.
Wrap Up
Conclusion
transitioncancel tells you a CSS transition was interrupted instead of finishing with transitionend. Listen with addEventListener, read TransitionEvent details when you need them, and handle both end and cancel for reliable cleanup.
Handle both transitionend and transitioncancel for cleanup
Give transitions a real duration/delay when you expect events
Log propertyName when several properties transition
Keep cancel handlers light and idempotent
❌ Don’t
Assume every transition stop fires transitionend
Expect events when duration and delay are both 0s
Forget that cancel replaces end for that transition
Confuse CSS Transitions with CSS Animations / Web Animations
Ignore multi-property cancel events (one per property)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about transitioncancel
CSS transition aborted—cleanup without waiting for transitionend.
5
Core concepts
🚫01
Means canceled
not finished
Event
🎨02
TransitionEvent
property + time
API
👁️03
Leave early
hover / class
Trigger
🔔04
addEventListener
preferred
Listen
🎯05
Baseline
widely available
Compat
❓ Frequently Asked Questions
It fires when a CSS transition is canceled — after transitionrun has occurred and before a normal transitionend. Common causes include reversing or removing the transition mid-flight (for example leaving a :hover state early, or removing the class that drove the change).
No. MDN does not mark Element transitioncancel as Deprecated, Experimental, or Non-standard. It is Baseline Widely available (across browsers since November 2020).
A TransitionEvent. Useful read-only properties include propertyName, elapsedTime, and pseudoElement.
Prefer element.addEventListener("transitioncancel", handler). You can also set ontransitioncancel where supported.
transitionend fires when a transition finishes its intended run. transitioncancel fires when the transition is aborted early. If transitioncancel fires, transitionend will not fire for that transition.
If there is no transition delay or duration — both are 0s or neither is declared — there is no transition, and none of the transition events fire.
Did you know?
MDN’s classic demo uses a long transition-delay plus hover: leave the box before the motion finishes and you get transitioncancel; stay until the end and you get transitionend. Same idea works with class toggles in try-it labs.