JavaScript - detect CSS3 transitionEnd
Table of Contents
#
JavaScript - Detect CSS3 transitionEnd
It is a event can fired when CSS3 transition end.
function transitionEnd() {
var el = document.createElement('div'), //what the hack is bootstrap
transEndEventNames = {
WebkitTransition : 'webkitTransitionEnd',
MozTransition : 'transitionend',
OTransition : 'oTransitionEnd otransitionend',
transition : 'transitionend'
};
for (var name in transEndEventNames) {
if (el.style[name] !== undefined) {
return transEndEventNames[name];
}
}
return false; // explicit for ie8 ( ._.)
}
// Usage
document.querySelector('body').addEventListener(transitionEnd(), function () {
// dosomething
});