Archivio tag: orientationchange

Tip: Fix random zoom on ipad orientation change

If you have the width set in the viewport :

<meta name = "viewport" content = "width=device-width; initial-scale=1.0;
 maximum-scale=1.0;"
/>

And then change the orientation it will randomly zoom in sometimes (especially if you are dragging on the screen) to fix this don’t set a width here I used :

<meta id="viewport" name="viewport" content="initial-scale=1.0; user-scalable=0;
minimum-scale=1.0; maximum-scale=1.0"
/>

This fixes the zoom whatever happens then you can use either window.onorientationchange event or if you want it to be platform independant (handy for testing) the window.innerWidth method.