Last active
August 29, 2015 14:17
-
-
Save reubenmoes/ffc933891740754c4e31 to your computer and use it in GitHub Desktop.
Modernizr Position Fixed + Transforms Combo Test
This file contains hidden or 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
//Test if browser supports position fixed and transforms in combination | |
//http://stackoverflow.com/questions/18572488/transform-doesnt-work-on-position-fixed-divs-on-android | |
Modernizr.addTest('fixedtransforms', function(){ | |
var css = '#modernizr { position: fixed; top: 0; left: 10px; width: 100%; height: 50px; -moz-transform: transformX(-20px); -ms-transform: translateX(-20px); -webkit-transform: translateX(-20px); transform: translateX(-20px); }'; | |
return Modernizr.testStyles(css, function(element, rule){ | |
//NOTE: Android gives false positives | |
return navigator.userAgent.indexOf('Android 4.1') === -1 && | |
navigator.userAgent.indexOf('Android 2.') === -1 && | |
element.getBoundingClientRect().left === -10; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment