-
-
Save jgonera/5250507 to your computer and use it in GitHub Desktop.
This version sandboxes el inside an iframe to avoid weird Android Browser quirks. Requires jQuery.
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 has3d(){ | |
var el = $('<p>')[0], $iframe = $('<iframe>'), has3d, t, | |
transforms = { | |
'webkitTransform': '-webkit-transform', | |
'OTransform': '-o-transform', | |
'msTransform': '-ms-transform', | |
'transform': 'transform' | |
}; | |
// Add it to the body to get the computed style | |
// Sandbox it inside an iframe to avoid Android Browser quirks | |
$iframe.appendTo('body').contents().find('body').append( el ); | |
for (t in transforms) { | |
if (el.style[t] !== undefined) { | |
el.style[t] = 'translate3d(1px,1px,1px)'; | |
has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); | |
} | |
} | |
$iframe.remove(); | |
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
Screw jQ....