Created
April 4, 2010 19:07
-
-
Save mislav/355625 to your computer and use it in GitHub Desktop.
Detect zoom factor on Mobile Safari
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* tested on the iPad and iPhone */ | |
function getZoomFactor() { | |
var deviceWidth, landscape = Math.abs(window.orientation) == 90 | |
// workaround for strange screen.height on the iPhone (v3.1.3) | |
if (window.screen.width == 320) deviceWidth = landscape ? 480 : 320 | |
else deviceWidth = window.screen[landscape ? "height" : "width"] | |
return deviceWidth / window.innerWidth | |
} |
what are those magic numbers 480
& 320
... seems suspiciously magical.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
wow! that looks much simpler