Skip to content

Instantly share code, notes, and snippets.

@webcyou
Last active January 24, 2017 12:25
Show Gist options
  • Save webcyou/a1093f2f1b4533cf3f7a to your computer and use it in GitHub Desktop.
Save webcyou/a1093f2f1b4533cf3f7a to your computer and use it in GitHub Desktop.
whichTransitionEvent & whichAnimationEvent
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