From 67495378cfb37c3c45a37be59e9b56d0cdf68e4b Mon Sep 17 00:00:00 2001 From: gorhill Date: Thu, 9 Oct 2014 10:41:20 -0400 Subject: [PATCH] this fixes #210 --- js/element-picker.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/js/element-picker.js b/js/element-picker.js index edb18a6cf..baefd30b7 100644 --- a/js/element-picker.js +++ b/js/element-picker.js @@ -280,8 +280,11 @@ var highlightElements = function(elems, force) { } } targetElements = elems; - var offx = window.pageXOffset; - var offy = window.pageYOffset; + + // https://github.com/gorhill/uBlock/issues/210 + var bodyRect = document.body.getBoundingClientRect(); + var offx = bodyRect.left; + var offy = bodyRect.top; var ow = svgRoot.getAttribute('width'); var ocean = [ 'M0 0', @@ -299,14 +302,14 @@ var highlightElements = function(elems, force) { } r = elem.getBoundingClientRect(); ocean.push( - 'M', r.left + offx, ' ', r.top + offy, + 'M', r.left - offx, ' ', r.top - offy, 'h', r.width, 'v', r.height, 'h-', r.width, 'z' ); islands.push( - 'M', r.left + offx, ' ', r.top + offy, + 'M', r.left - offx, ' ', r.top - offy, 'h', r.width, 'v', r.height, 'h-', r.width,