-
-
Save jerone/3810309 to your computer and use it in GitHub Desktop.
Testing for CSS 3D Transforms Support
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
function has3D() { | |
var has3D, | |
el = document.createElement("p"), | |
transforms = { | |
'WebkitTransform': '-webkit-transform', | |
'OTransform': '-o-transform', | |
'MSTransform': '-ms-transform', | |
'MozTransform': '-moz-transform', | |
'Transform': 'transform' | |
}; | |
document.body.insertBefore(el, document.body.lastChild); | |
for (var t in transforms) { | |
if (el.style[t] !== undefined) { | |
el.style[t] = "translate3d(0,0,0)"; | |
has3D = window.getComputedStyle(el).getPropertyValue(transforms[t]); | |
break; | |
} | |
} | |
document.body.removeChild(el); | |
return (has3D !== undefined && has3D.length > 0 && has3D !== "none"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment