Last active
January 24, 2017 12:25
-
-
Save webcyou/a1093f2f1b4533cf3f7a to your computer and use it in GitHub Desktop.
whichTransitionEvent & whichAnimationEvent
This file contains 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
var vendor = { | |
name: "", | |
browser: "", | |
prefix: "", | |
transitionend: whichTransitionEvent(), | |
animationend: whichAnimationEvent() | |
}; | |
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]; | |
} | |
} | |
} | |
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]; | |
} | |
} | |
} | |
return vendor; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment