Last active
August 29, 2015 14:14
-
-
Save matthewlein/0bb51e7dd8cb8b3da9ca to your computer and use it in GitHub Desktop.
jQuery.animationDuration.js
This file contains hidden or 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
// ************************************************************************* // | |
// | |
// 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