Skip to content

Instantly share code, notes, and snippets.

@julescarbon
Created March 18, 2014 16:40
Show Gist options
  • Save julescarbon/9623953 to your computer and use it in GitHub Desktop.
Save julescarbon/9623953 to your computer and use it in GitHub Desktop.
// Check if supports 3D transforms
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