Detecting 'transform: translate3d' support

function has3d() { var el = document.createElement('p'), has3d, transforms = { 'WebkitTransform':'-webkit-transform', 'OTransform':'-o-transform', 'MSTransform':'-ms-transform', 'MozTransform':'-moz-transform', 'Transform':'transform' }; // Add it to the body to get the computed style. document.body.insertBefore(el, null); for (var t in transforms) { if (el.style[t] !== undefined) { el.style[t] = "translate3d(1px,1px,1px)"; has3d = window.getComputedStyle(el).getPropertyValue(transforms[t]); } } document.body.removeChild(el); return (has3d !== undefined && has3d.length > 0 && has3d !== "none"); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.