Created
May 8, 2013 20:08
-
-
Save aduth/5543247 to your computer and use it in GitHub Desktop.
Convert CSS3 transition duration string to milliseconds
This file contains 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
var transitionDurationToMilliseconds = function(duration) { | |
var pieces = duration.match(/^([\d\.]+)(\w+)$/), | |
time, unit, multiplier; | |
if (pieces.length <= 1) { | |
return duration; | |
} | |
time = pieces[1]; | |
unit = pieces[2]; | |
switch(unit) { | |
case 'ms': multiplier = 1; break; | |
case 's': multiplier = 1000; break; | |
} | |
return time * multiplier; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment