18 Jan 2012 11:32 AM #1
How to determine current screen orientation
How can I determine on an ad-hoc basis what the screen orientation is of the device being used?
I know I can listen for the orientation change event on the viewport, but what about when the user first loads up the application, how can I determine this through code?
18 Jan 2012 3:49 PM #2
I would look at window.innerWidth and window.innerHeight and infer the orientation from there.
26 Jan 2012 3:54 AM #3
Yeah, that's strange to have an event to tell about value changes, but no way to get the current value.
You could call
which returns "portrait" or "landscape" but that method is not documented to be public.
You could also look at the code (in viewport/Default.js) and copy it, or request that the method is made public.
26 Jan 2012 8:54 PM #4