Skip to content

Instantly share code, notes, and snippets.

@amycheng
Created April 30, 2013 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amycheng/5492444 to your computer and use it in GitHub Desktop.
Save amycheng/5492444 to your computer and use it in GitHub Desktop.
a simple jQuery plugin for creating callbacks for CSS3 transitions
$.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