Skip to content

Instantly share code, notes, and snippets.

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