Created
October 11, 2017 09:59
-
-
Save dmjcomdem/9ae0aaaf4e4d24ed33f02e5bf884c0e6 to your computer and use it in GitHub Desktop.
Detect the supported event property name
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(); | |
$(".button").click(function(){ | |
$(this).addClass("animate"); | |
$(this).one(transitionEvent, | |
function(event) { | |
// Do something when the transition ends | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment