Created
September 21, 2010 03:15
-
-
Save dryan/589133 to your computer and use it in GitHub Desktop.
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
function getElementTransitionDuration(elem, property) { | |
// this currently only supports Webkit browsers, but should be easy enough to apply to others as they begin to support CSS transitions | |
var td = elem ? window.getComputedStyle(elem)['-webkit-transition-duration'].split(', ') : [], | |
tp = elem ? window.getComputedStyle(elem)['-webkit-transition-property'].split(', ') : [], | |
durations = {}, | |
longest = 0, | |
i = td.length; | |
while( --i ) { | |
var dur = parseFloat(td[i], 10); | |
if(i < tp.length) { | |
durations[tp[i]] = dur; | |
} | |
longest = dur > longest ? dur : longest; | |
} | |
if(!property) { | |
return longest; | |
} else if(durations[property]) { | |
return durations[property]; | |
} else { | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment