How do I reset the scale/zoom of a web app on an orientation change on the iPhone?
Posted
by Elisabeth
on Stack Overflow
See other posts from Stack Overflow
or by Elisabeth
Published on 2010-04-01T02:33:42Z
Indexed on
2010/04/01
3:13 UTC
Read the original article
Hit count: 479
I'm having the same problem that a couple of others have had with getting the correct behavior in a web app on an orientation change, and there doesn't seem to be an obvious solution - I've seen this question asked a couple of times on Stack Overflow and no one's yet been able to answer it.
When I start the app in portrait mode, it works fine. Then I rotate into landscape and it's scaled up. To get it to scale correctly for the landscape mode I have to double tap on something twice, first to zoom all the way in (the normal double tap behavior) and again to zoom all the way out (again, the normal double tap behavior). When it zooms out, it zooms out to the correct NEW scale for landscape mode.
Switching back to portrait seems to work more consistently; that is, it handles the zoom so that the scale is correct when the orientation changes back to portrait.
I am trying to figure out if this is a bug? or if this is something that can be fixed with Javascript?
With the viewport meta content, I am setting the initial-scale to 1.0 and I am NOT setting minimum or maximum scale (nor do I want to). I am setting the width to device-width.
Any ideas? I know a lot of people would be grateful to have a solution as it seems to be a persistent problem.
Thank you!
© Stack Overflow or respective owner