Created
August 27, 2013 16:05
-
-
Save veganben/6355552 to your computer and use it in GitHub Desktop.
You don't always need to know which way up a device is being held. You just need to be able to access the values for height and width. This seems to work:
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
| var devicePixelRatio = window.devicePixelRatio || 1, | |
| ww = devicePixelRatio * (window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth), | |
| wh = devicePixelRatio * (window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight); | |
| // width, height | |
| var landscape = [Math.max(ww, wh), Math.min(ww, wh)]; | |
| var portrait = [Math.min(ww, wh), Math.max(ww ,wh)]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment