Created
April 30, 2013 22:29
-
-
Save amycheng/5492444 to your computer and use it in GitHub Desktop.
a simple jQuery plugin for creating callbacks for CSS3 transitions
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
$.fn.transitionEnd = function(callback) { | |
//plugin for detecting the end of a transition and then doing a callback | |
$(this).one('webkitTransitionEnd otransitionend msTransitionEnd transitionend', | |
function(e) { | |
if (typeof callback == 'function') { | |
callback.call(this); | |
} | |
}); | |
}; | |
/* | |
Usage: | |
$('#box').transitionEnd(function(){ | |
alert('done!') | |
}); | |
*/ | |
/* | |
Reference: | |
http://blog.teamtreehouse.com/using-jquery-to-detect-when-css3-animations-and-transitions-end | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment