Skip to content

Instantly share code, notes, and snippets.

@ThierryA
Created December 23, 2015 13:04
Show Gist options
  • Save ThierryA/a28c10efb34b8ae90252 to your computer and use it in GitHub Desktop.
Save ThierryA/a28c10efb34b8ae90252 to your computer and use it in GitHub Desktop.
jQuery: call after CSS transition.
(function ($) {
"use strict";
function afterTransition( element, callback ) {
var transitions = [0];
// Check if the transition has a duration.
element.each( function() {
var time = parseFloat( $(this).css( 'transition-duration' ).replace( /[^\d.]/g, '' ) );
if ( 0 < time )
transitions.push( ( time * 1000 ) );
});
setTimeout( function() {
callback();
}, Math.max.apply( Math, transitions ) );
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment