Last active
August 29, 2015 14:00
-
-
Save simeydotme/11055176 to your computer and use it in GitHub Desktop.
a jQuery function to get either all the transition times or just the longest css transition time on an element.
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
function getTransitionSpeed( $el , returnWholeArray ) { | |
returnWholeArray = returnWholeArray || false; | |
var speed = $el.css("transition-duration").split(","), | |
speedLength = speed.length; | |
for( var i = 0; i < speedLength; i++) { | |
var multiplier = 1000; | |
speed[i] = | |
speed[i] | |
.replace(" ","") | |
.replace("s",""); | |
speed[i] = parseFloat( speed[i] ) * multiplier; | |
} | |
if( returnWholeArray ) { | |
return speed; | |
} else { | |
return Math.max.apply(Math, speed); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment