Skip to content

Instantly share code, notes, and snippets.

@matthewlein
Last active August 29, 2015 14:14
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 matthewlein/0bb51e7dd8cb8b3da9ca to your computer and use it in GitHub Desktop.
Save matthewlein/0bb51e7dd8cb8b3da9ca to your computer and use it in GitHub Desktop.
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