Skip to content

Instantly share code, notes, and snippets.

Created December 30, 2012 20:04
Show Gist options
  • Save maccman/4414792 to your computer and use it in GitHub Desktop.
Save maccman/4414792 to your computer and use it in GitHub Desktop.
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
for(t in transitions){
if([t] !== undefined ){
return transitions[t];
Copy link

Two questions, please.

1 -
Is it really needed to do fake element?
document.body has some bugs or wrong behavior?

2 - WebkitTransition. it is strange that in console present only lower case webkitTransition.
And from IE9 this works"-webkit-transition", "left 2s linear");

Copy link

cubiq commented Apr 6, 2013

I would suggest to simply register all transitionend events for all vendors. do we really need to spoof them?

Copy link

ionutzp commented Jul 19, 2013

I have successfully used callbacks by registering the events for all browsers so i would recommend that.
eg: this.$el.on('webkitTransitionEnd transitionend msTransitionEnd oTransitionEnd', function(event) { ...

Copy link

davidsm commented Oct 4, 2013

You shouldn't register all events. The reason for this is that at least Chrome as of version 29 will fire off both webkitTransitionEnd and transitionend. So your function will fire twice.

Copy link

Hengjie commented Mar 29, 2014

The way you get around firing function twice is to add a namespace to the event name and turning them all off once one of them have been executed.

this.$el.on('webkitTransitionEnd.blah transitionend.blah msTransitionEnd.blah oTransitionEnd.blah', function(event) {

Obviously, replace blah with your own namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment