aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authormrmr19932017-09-14 19:40:16 +0100
committermrmr19932017-09-14 19:40:16 +0100
commit12826329347221b46496c6ff5dfa390c20a01585 (patch)
tree52d74a0e2ad0a1373f30d6d5ef413f8572b4e748 /lib
parente60f329eb6180cbe3261adf582ee4df3cdc0b0fe (diff)
downloadvimium-12826329347221b46496c6ff5dfa390c20a01585.tar.bz2
Always use getBoundingClientRect for getViewportTopLeft
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index d0bd4615..21a80330 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -291,12 +291,16 @@ DomUtils =
getViewportTopLeft: ->
box = document.documentElement
style = getComputedStyle box
+ rect = box.getBoundingClientRect()
+ {clientTop, clientLeft} = box
if style.position == "static" and not /content|paint|strict/.test(style.contain or "")
- zoom = +style.zoom || 1
- top: Math.ceil(window.scrollY / zoom), left: Math.ceil(window.scrollX / zoom)
+ # The margin is included in the client rect, so we need to subtract it back out.
+ marginTop = parseInt style.marginTop
+ marginLeft = parseInt style.marginLeft
+ top: -rect.top + marginTop, left: -rect.left + marginLeft
else
- rect = box.getBoundingClientRect()
- top: -rect.top - box.clientTop, left: -rect.left - box.clientLeft
+ top: -rect.top - clientTop, left: -rect.left - clientLeft
+
suppressPropagation: (event) ->
event.stopImmediatePropagation()