Created
February 4, 2016 15:30
-
-
Save dmacompton/5331ae1bfea1b2f6bb23 to your computer and use it in GitHub Desktop.
JS isRetina()
This file contains 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
isRetina = function(){ | |
var mediaQuery = '(-webkit-min-device-pixel-ratio: 1.5), (min--moz-device-pixel-ratio: 1.5), (-o-min-device-pixel-ratio: 3/2), (min-resolution: 1.5dppx)'; | |
var root = (typeof exports === 'undefined' ? window : exports); | |
if (root.devicePixelRatio > 1) { | |
return true; | |
} | |
if (root.matchMedia && root.matchMedia(mediaQuery).matches) { | |
return true; | |
} | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment