I'd like to delete an object after it's done animating with a CSS transition, but I'm not able to use a JavaScript library.
How do I detect when the animation is done? Do I use a callback or custom event somehow?
element.addEventListener('transitionend', function(event) {
alert("CSS Property completed: " + event.propertyName);
}, false );
For now, the exact event name has not been standardized. Here's a quote from MDN:
There is a single event that is fired when transitions complete.
In all standard-compliant browser, the event istransitionend
,
in WebKit it iswebkitTransitionEnd
.
Here's the fiddle for Webkit: http://jsfiddle.net/bNgWY/