From da2be746332c69326b008f555aec2f1a166de7b0 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 8 Oct 2016 14:14:37 +0100 Subject: Better positioning of link-hints flash rect. When an spans the end of a line and the start of the next line, we now highlight both parts of the link (instead of just the first). Also, refactor code for calculating the position of the viewport into a separate utility in DomUtils. --- lib/dom_utils.coffee | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib') diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 8e953405..82c13287 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -288,6 +288,13 @@ DomUtils = flashEl = @addFlashRect rect setTimeout((-> DomUtils.removeElement flashEl), 400) + getViewportTopLeft: -> + if getComputedStyle(document.documentElement).position == "static" + top: window.scrollY, left: window.scrollX + else + rect = document.documentElement.getBoundingClientRect() + top: -rect.top, left: -rect.left + suppressPropagation: (event) -> event.stopImmediatePropagation() -- cgit v1.2.3