Created
December 23, 2015 13:04
-
-
Save ThierryA/a28c10efb34b8ae90252 to your computer and use it in GitHub Desktop.
jQuery: call after CSS transition.
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
(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