Lots of cool talk. By https://jonsuh.com/blog/detect-the-end-of-css-animations-and-transitions-with-javascript/
Created
September 24, 2015 11:41
-
-
Save lukewhitehouse/d2e4792b226505d93895 to your computer and use it in GitHub Desktop.
On Animation or Transition end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whichAnimationEvent(){ | |
var t, | |
el = document.createElement("fakeelement"); | |
var animations = { | |
"animation" : "animationend", | |
"OAnimation" : "oAnimationEnd", | |
"MozAnimation" : "animationend", | |
"WebkitAnimation": "webkitAnimationEnd" | |
} | |
for (t in animations){ | |
if (el.style[t] !== undefined){ | |
return animations[t]; | |
} | |
} | |
} | |
var animationEvent = whichAnimationEvent(); | |
// Test for animation end | |
$('.element').one(animationEvent, function(event) { | |
console.log('animation has ended'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function whichTransitionEvent(){ | |
var t, | |
el = document.createElement("fakeelement"); | |
var transitions = { | |
"transition" : "transitionend", | |
"OTransition" : "oTransitionEnd", | |
"MozTransition" : "transitionend", | |
"WebkitTransition": "webkitTransitionEnd" | |
} | |
for (t in transitions){ | |
if (el.style[t] !== undefined){ | |
return transitions[t]; | |
} | |
} | |
} | |
var transitionEvent = whichTransitionEvent(); | |
// Test for transition end | |
$('.element').one(transitionEvent, function(event) { | |
console.log('transition has ended'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment