diff options
| author | gdh1995 | 2016-12-12 01:02:00 +0800 | 
|---|---|---|
| committer | gdh1995 | 2017-01-03 16:44:40 +0800 | 
| commit | 0338c08ed7a15e11363b6218da8cb495b769ecfa (patch) | |
| tree | f558ecaba90ad74d208c7fec84a7c1163488ec62 /lib/dom_utils.coffee | |
| parent | b12ed93d0b96df90511d3331e8a5f54e7b1b7da4 (diff) | |
| download | vimium-0338c08ed7a15e11363b6218da8cb495b769ecfa.tar.bz2 | |
getViewportTopLeft: support zoomed static documentElement
if `document.documentElement` is zoomed, Vimium's hints `<div>` are also zoomed,
and then `scrollY` may be not equal with viewport client rect's `top`.
Example:
* make the tab zoom level is 1, `documentElement`'s `zoom` style is 2
* open a page, scroll to the top left corner
* press `f`, and all things are right
* exit LinkHints mode, scroll down for 100px, and then press `f`
* this time all hints has moved down 200px from the correct place
Diffstat (limited to 'lib/dom_utils.coffee')
| -rw-r--r-- | lib/dom_utils.coffee | 6 | 
1 files changed, 4 insertions, 2 deletions
| diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index fad5ffbf..d39ce1de 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -289,8 +289,10 @@ DomUtils =      setTimeout((-> DomUtils.removeElement flashEl), 400)    getViewportTopLeft: -> -    if getComputedStyle(document.documentElement).position == "static" -      top: window.scrollY, left: window.scrollX +    style = getComputedStyle document.documentElement +    if style.position == "static" +      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 | 
