Skip to content

Commit

Permalink
Introduce a hidden element as a reference for zoom computation
Browse files Browse the repository at this point in the history
Rather than rely on the change in body position to compute the mobile
zoom compensation introduce a hidden, absolutely position element whose
offset can be measured.  The body element can be offset due to vertical
margin collapse even when the element itself is positioned at the
origin. When this happens the body offset measurements become unreliable.
  • Loading branch information
Joel Steres committed Jun 12, 2017
1 parent c3e37d0 commit 914f9e8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,20 @@ function countFlags(value) {
* positioned at 0,0.
*/
function activateChromeZoomedOffsetPatch() {
var style;
if (/Chrome\/[.0-9]*/.test(navigator.userAgent)) {
session.chromePatchRefElement = $(document.body);
style = {
top: 0,
left: 0,
position: 'absolute',
display: 'hidden',
height: '1px',
margin: 0,
width: '1px',
zIndex: -1
};
session.chromePatchRefElement = $('<div/>').css(style).appendTo($(document.body));
}
}

Expand Down

0 comments on commit 914f9e8

Please sign in to comment.