Last active
December 21, 2015 13:29
-
-
Save adeubank/6313285 to your computer and use it in GitHub Desktop.
Detect if a browser supports a CSS feature. Courtesy of Stack Overflow. http://stackoverflow.com/questions/10888211/detect-support-for-transition-with-javascript
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
/** | |
* Detect if a browser supports a CSS feature. | |
* Courtesy of Stack Overflow. | |
* http://stackoverflow.com/questions/10888211/detect-support-for-transition-with-javascript | |
* | |
*/ | |
function detectCSSFeature(featurename){ | |
var feature = false, | |
domPrefixes = 'Webkit Moz ms O'.split(' '), | |
elm = document.createElement('div'), | |
featurenameCapital = null; | |
featurename = featurename.toLowerCase(); | |
if( elm.style[featurename] ) { feature = true; } | |
if( feature === false ) { | |
featurenameCapital = featurename.charAt(0).toUpperCase() + featurename.substr(1); | |
for( var i = 0; i < domPrefixes.length; i++ ) { | |
if( elm.style[domPrefixes[i] + featurenameCapital] !== undefined ) { | |
feature = true; | |
break; | |
} | |
} | |
} | |
return feature; | |
} | |
detectCSSFeature("transition"); // => true or false depending on your browser. Let's hope it's true. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment