Skip to content

Instantly share code, notes, and snippets.

@reubenmoes
Last active August 29, 2015 14:17
Show Gist options
  • Save reubenmoes/ffc933891740754c4e31 to your computer and use it in GitHub Desktop.
Save reubenmoes/ffc933891740754c4e31 to your computer and use it in GitHub Desktop.
Modernizr Position Fixed + Transforms Combo Test
//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