all articles

how to get zoom level on iOS

2015-07-03 @sunderls

iOS zoomlevel js

description, bug

how to get zoomLevel on iOS?

solution

since on zooming, window.innerWidth changes while screen.width remains the same,

and on rotating, window.innerWidth changes while screen.width stills keeps the same.

code

function getZoomLevelOnIOS(){
     return ( Math.abs(window.orientation) === 90 ? screen.height : screen.width) / window.innerWidth;
}