Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
jQuery.animationDuration.js
// ************************************************************************* //
//
// Get the length of a CSS transition or animation
//
// ************************************************************************* //
(function($){
$.fn.transitionDuration = function() {
// check the main transition duration property
if( this.css('transition-duration') ) {
return Math.round( parseFloat( this.css('transition-duration') ) * 1000 );
}
// if we're here, then no transition duration was found, return 0
return 0;
};
$.fn.animationDuration = function() {
// check the main animation duration property
if( this.css('animation-duration' )) {
return Math.round( parseFloat( this.css('animation-duration') ) * 1000) ;
}
// if we're here, then no animation duration was found, return 0
return 0;
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment