From 914f9e8a64c22a88d230fcb0014ea97f92998d3a Mon Sep 17 00:00:00 2001 From: Joel Steres Date: Sun, 4 Dec 2016 23:25:54 -0700 Subject: [PATCH] Introduce a hidden element as a reference for zoom computation 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. --- src/utility.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/utility.js b/src/utility.js index 703644ab..9b51be91 100644 --- a/src/utility.js +++ b/src/utility.js @@ -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 = $('
').css(style).appendTo($(document.body)); } }