From a6ee639ecaf758fbe4652b5d70beaa607821ca04 Mon Sep 17 00:00:00 2001 From: gdh1995 Date: Thu, 22 Dec 2016 22:28:24 +0800 Subject: take documentElement's border into consideration --- lib/dom_utils.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 7232bb45..e6616f51 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -289,13 +289,14 @@ DomUtils = setTimeout((-> DomUtils.removeElement flashEl), 400) getViewportTopLeft: -> - style = getComputedStyle document.documentElement + box = document.documentElement + style = getComputedStyle 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) else - rect = document.documentElement.getBoundingClientRect() - top: -rect.top, left: -rect.left + rect = box.getBoundingClientRect() + top: -rect.top - box.clientTop, left: -rect.left - box.clientLeft suppressPropagation: (event) -> event.stopImmediatePropagation() -- cgit v1.2.3