From d14ec3b571df2d0581506e329e593d5cd2344aa7 Mon Sep 17 00:00:00 2001 From: gdh1995 Date: Fri, 7 Oct 2016 01:51:49 +0800 Subject: handle documentElement's top margin correctly --- content_scripts/link_hints.coffee | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'content_scripts/link_hints.coffee') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index c86eabf1..b5fa527d 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -811,9 +811,16 @@ LocalHints = nonOverlappingElements.push visibleElement unless visibleElement.secondClassCitizen # Position the rects within the window. + if getComputedStyle(document.documentElement).position == "static" + top = window.scrollY + left = window.scrollX + else + rect = document.documentElement.getBoundingClientRect() + top = -rect.top + left = -rect.left for hint in nonOverlappingElements - hint.rect.top += window.scrollY - hint.rect.left += window.scrollX + hint.rect.top += top + hint.rect.left += left if Settings.get "filterLinkHints" @withLabelMap (labelMap) => -- cgit v1.2.3