aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorStephen Blott2016-01-31 16:35:26 +0000
committerStephen Blott2016-01-31 16:35:26 +0000
commit63e2387853d69b39454e71ec8006d2b512e86248 (patch)
tree80c902e617ff950b8c7ec926e0d692f9647dce08 /lib
parentb14082d0021830c5359e7fc5f81175941e9319ad (diff)
downloadvimium-63e2387853d69b39454e71ec8006d2b512e86248.tar.bz2
Fix visual indicator for `focusInput()`.
Currently, if an input is only partially in the view port, then the page may scroll when it is focused and the overlays for `focusInput()` are wonky. See #1257. Here, we draw the overlay around the *entire* input, instead of just around the visible part. Being partially visible therefore is no longer relevant. Fixes #1257. Closes #1258.
Diffstat (limited to 'lib')
-rw-r--r--lib/dom_utils.coffee12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee
index 7473df17..5284c813 100644
--- a/lib/dom_utils.coffee
+++ b/lib/dom_utils.coffee
@@ -116,6 +116,18 @@ DomUtils =
null
#
+ # Returns the smallest rectangle which encloses element. Assumes that there is at least one rectangle.
+ #
+ getBoundingClientRect: (element) ->
+ [clientRect, rects...] = element.getClientRects()
+ for rect in rects
+ clientRect.top = Math.min clientRect.top, rect.top
+ clientRect.bottom = Math.max clientRect.bottom, rect.bottom
+ clientRect.left = Math.min clientRect.left, rect.left
+ clientRect.right = Math.max clientRect.right, rect.right
+ extend clientRect, width: clientRect.right - clientRect.left, height: clientRect.bottom - clientRect.top
+
+ #
# Bounds the rect by the current viewport dimensions. If the rect is offscreen or has a height or width < 3
# then null is returned instead of a rect.
#