Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Webkit Mobile: use orientation to choose device width from screen.(wi…

…dth|height)
  • Loading branch information...
commit 4aa9ccc919a2dad36a5442c2c4b5fb7c2bc6ce28 1 parent e9df8c7
@skeltoac authored
Showing with 9 additions and 3 deletions.
  1. +9 −3 detect-zoom.js
View
12 detect-zoom.js
@@ -65,10 +65,16 @@ var DetectZoom = {
},
_zoomWebkitMobile: function() {
// the trick: window.innerWIdth is in CSS pixels, while
- // documentElement.clientWidth is in system pixels.
+ // screen.width and screen.height are in system pixels.
// And there are no scrollbars to mess up the measurement.
- var z = document.documentElement.clientWidth / window.innerWidth;
- var devicePixelRatio = window.devicePixelRatio != null ? window.devicePixelRatio : 1;
+ var devicePixelRatio = window.devicePixelRatio != null ? window.devicePixelRatio : 1
+ , deviceWidth;
+ if ( Math.abs(window.orientation) == 90 ) {
+ deviceWidth = screen.height;
+ } else {
+ deviceWidth = screen.width;
+ }
+ var z = deviceWidth / window.innerWidth;
// return immediately; don't round at the end.
return {zoom: z, devicePxPerCssPx: z*devicePixelRatio};
},

0 comments on commit 4aa9ccc

Please sign in to comment.
Something went wrong with that request. Please try again.