diff options
| author | Stanley Shyiko | 2013-10-28 22:13:37 +0200 |
|---|---|---|
| committer | Stanley Shyiko | 2013-10-28 22:13:37 +0200 |
| commit | 88cbe89247a4ebdf9498d77eb0f7e675b7a4c785 (patch) | |
| tree | 477890b727fa2f2c5dadf6b01caac08363e56e99 /lib/dom_utils.coffee | |
| parent | 610ce8aaab164ace9f60d83773b382f4d7978140 (diff) | |
| download | vimium-88cbe89247a4ebdf9498d77eb0f7e675b7a4c785.tar.bz2 | |
Fixed detection of links which are only partially inside the viewport
Diffstat (limited to 'lib/dom_utils.coffee')
| -rw-r--r-- | lib/dom_utils.coffee | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 38b23202..70e52a6c 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -46,11 +46,21 @@ DomUtils = # getVisibleClientRect: (element) -> # Note: this call will be expensive if we modify the DOM in between calls. - clientRects = element.getClientRects() + clientRects = ({ + top: clientRect.top, right: clientRect.right, bottom: clientRect.bottom, left: clientRect.left, + width: clientRect.width, height: clientRect.height + } for clientRect in element.getClientRects()) for clientRect in clientRects - if (clientRect.top < -2 || clientRect.top >= window.innerHeight - 4 || - clientRect.left < -2 || clientRect.left >= window.innerWidth - 4) + if (clientRect.top < 0) + clientRect.height += clientRect.top + clientRect.top = 0 + + if (clientRect.left < 0) + clientRect.width += clientRect.left + clientRect.left = 0 + + if (clientRect.top >= window.innerHeight - 4 || clientRect.left >= window.innerWidth - 4) continue if (clientRect.width < 3 || clientRect.height < 3) |
