Skip to content

Commit

Permalink
Merge pull request Modernizr#1513 from jacobrossi/transforms3d-atmedia
Browse files Browse the repository at this point in the history
csstransform3d detect should prefer css conditionals - fixes Modernizr#1512
  • Loading branch information
patrickkettner committed Feb 5, 2015
2 parents 8aa80ae + a54308e commit d0b5fc0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions feature-detects/css/transforms3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
}
!*/
define(['Modernizr', 'testAllProps', 'testStyles', 'docElement'], function( Modernizr, testAllProps, testStyles, docElement ) {
define(['Modernizr', 'testAllProps', 'testStyles', 'docElement', 'test/css/supports'], function( Modernizr, testAllProps, testStyles, docElement ) {
Modernizr.addTest('csstransforms3d', function() {
var ret = !!testAllProps('perspective', '1px', true);
var usePrefix = Modernizr._config.usePrefixes;
Expand All @@ -19,12 +19,17 @@ define(['Modernizr', 'testAllProps', 'testStyles', 'docElement'], function( Mode
// 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 && (!usePrefix || 'webkitPerspective' in docElement.style )) {

// Webkit allows this media query to succeed only if the feature is enabled.
// `@media (transform-3d),(-webkit-transform-3d){ ... }`
var mq;
// Use CSS Conditional Rules if available
if (Modernizr.supports) {
mq = '@supports (perspective: 1px)';
} else {
// Otherwise, Webkit allows this media query to succeed only if the feature is enabled.
// `@media (transform-3d),(-webkit-transform-3d){ ... }`
mq = '@media (transform-3d)';
if (usePrefix ) mq += ',(-webkit-transform-3d)';
}
// If loaded inside the body tag and the test element inherits any padding, margin or borders it will fail #740
var mq = '@media (transform-3d)';
if (usePrefix ) mq += ',(-webkit-transform-3d)';
mq += '{#modernizr{left:9px;position:absolute;height:5px;margin:0;padding:0;border:0}}';

testStyles(mq, function( elem ) {
Expand Down

0 comments on commit d0b5fc0

Please sign in to comment.