Skip to content

Instantly share code, notes, and snippets.

@DChinin
Last active December 23, 2015 04:29
Show Gist options
  • Save DChinin/6580403 to your computer and use it in GitHub Desktop.
Save DChinin/6580403 to your computer and use it in GitHub Desktop.
Return true if browser support CSS feature
// prop - transition, animation etc.
function featureDetect(prop) {
prop = prop.replace(/-(\w)/g, function (s, g) {
return g.toUpperCase()
});
var pre = ',Icab,Khtml,Moz,Ms,O,Webkit'.split(',');
for (var i = 0; i < pre.length; ++i) {
if (i == 1) {
prop = prop.slice(0, 1).toUpperCase() + prop.slice(1);
}
if (pre[i] + prop in document.documentElement.style) {
return true;
}
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment