Created
June 18, 2014 19:24
-
-
Save weotch/a06d4efeb57a39b0cb10 to your computer and use it in GitHub Desktop.
Custom modernizr tests
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
<script src="/js/libs/modernizr.js"></script> | |
<script type="text/javascript"> | |
var ua = navigator.userAgent; | |
Modernizr.addTest('retina', window.devicePixelRatio > 1); | |
Modernizr.addTest('webkit', navigator.userAgent.match(/AppleWebKit/i)); | |
Modernizr.addTest('ipad', navigator.userAgent.match(/iPad/i)); | |
Modernizr.addTest('iphone', navigator.userAgent.match(/iPhone/i)); | |
Modernizr.addTest('ipod', navigator.userAgent.match(/iPod/i)); | |
Modernizr.addTest('ios', Modernizr.ipad || Modernizr.ipod || Modernizr.iphone); | |
Modernizr.addTest('android', navigator.userAgent.match(/Android/i)); | |
// Videos won't autoplay on iOS, so don't allow them | |
Modernizr.addTest('inlinevideos', Modernizr.video && !Modernizr.ios && !Modernizr.android); | |
// Background-attachment:fixed fails on webkit when there are videos and on iOS. | |
Modernizr.addTest('fixedbkgd', !Modernizr.webkit || (Modernizr.webkit && !Modernizr.inlinevideos && !Modernizr.ios && !Modernizr.android)); | |
// Android doesn't display canvas animations well | |
Modernizr.addTest('easel', Modernizr.canvas && Modernizr.canvastext && !Modernizr.android); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment