Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
iOS4 reports landscape when it's in portrait #3707
This was actually a regression I introduced when I added the fix for bug #
The problem is that there is a bug in iPhone and iPod Touch devices that run iOS 4.1 and later (last checked up to iOS 5.1) where the browser ALWAYS triggers a landscape media query, no matter what orientation the device is currently in. This does NOT happen on iPad.
I filed bug 11064902 with Apple on http://bugreport.apple.com .
This may force us to resort to checking window dimensions. The one problem, at least on the iPhone/iPodTouch, is that when the user turns on the developer console for the browser, this actually makes the window width larger than the window height (320 x 306) when in portrait mode. We also can't rely on screen.width/height or screen.availWidth/availHeight because those values are always the same no matter what orientation the device is in. That is, the width and height values always report as if the device is in portrait mode.
Also, for some reason, it looks like window.innerWidth/innerHeight, window.outerWidth/outerHeight, $( window ).width()/height() all report the same values.
What I'm thinking is that perhaps we will need to do something like this:
Worst case scenario, we are no-better than 1.0, assuming that window.orientation values of 0 and 180 mean portrait.
FYI, I just tested the proposed threshold workaround above and it seems to work well. I tested on
added a commit
Apr 5, 2012
Just tested Kin's fix and it works perfectly. I loaded the page in both orientations then rotated each a few times and it was always accurate. The only issue is the Palm Pixi has basically a square screen so it read as portrait but this is sort of an edge case so it's not a concern. This is ready to land IMHO.
Results from this page: http://jquerymobile.com/branches/1.2/tests/functional/orientation.html
Kindle Fire (2.3) - works
Palm Pixi (1.4) - reports portrait on both orientations, but screen is square