UNPKG

modernizr

Version:

Modernizr is a JavaScript library that detects HTML5 and CSS3 features in the user’s browser.

33 lines (29 loc) 1.44 kB
/*! { "name": "CSS Transforms 3D", "property": "csstransforms3d", "caniuse": "transforms3d", "tags": ["css"], "warnings": [ "Chrome may occassionally fail this test on some systems; more info: https://code.google.com/p/chromium/issues/detail?id=129004" ] } !*/ define(['Modernizr', 'testAllProps', 'testStyles', 'docElement'], function( Modernizr, testAllProps, testStyles, docElement ) { Modernizr.addTest('csstransforms3d', function() { var ret = !!testAllProps('perspective'); // Webkit's 3D transforms are passed off to the browser's own graphics renderer. // It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in // some conditions. As a result, Webkit typically recognizes the syntax but // will sometimes throw a false positive, thus we must do a more thorough check: if ( ret && 'webkitPerspective' in docElement.style ) { // Webkit allows this media query to succeed only if the feature is enabled. // `@media (transform-3d),(-webkit-transform-3d){ ... }` // If loaded inside the body tag and the test element inherits any padding, margin or borders it will fail #740 testStyles('@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:5px;margin:0;padding:0;border:0}}', function( node, rule ) { ret = node.offsetLeft === 9 && node.offsetHeight === 5; }); } return ret; }); });