diff options
author | Solly Ross <sross@redhat.com> | 2015-02-25 17:02:16 -0500 |
---|---|---|
committer | Solly Ross <sross@redhat.com> | 2015-02-27 13:37:13 -0500 |
commit | 7e54fb93dd60f4cb08685a3a747f8f0a691519cf (patch) | |
tree | 4b037558429483d7595bcd49e6511ac7479c3950 | |
parent | 20d3fb66659e2f30417d7cbb255e34e079677e66 (diff) | |
download | novnc-7e54fb93dd60f4cb08685a3a747f8f0a691519cf.tar.gz |
Make Util.getPosition be relative to page
Commit 5108c4635c847de9be0edadf572f7426f351b66a caused a regression
in the case where scrolling is used -- getPosition return position
relative to the viewport, while getEventPosition expected a position
relative to the page.
As per
https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect,
the fix for this is simply to add the `pageXOffset` and `pageYOffset` to
the output of `getBoundingClientRect()`.
Fixes #459.
-rw-r--r-- | include/util.js | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/util.js b/include/util.js index 482b10c..effb070 100644 --- a/include/util.js +++ b/include/util.js @@ -436,7 +436,7 @@ Util.load_scripts = function (files) { Util.getPosition = function(obj) { "use strict"; var objPosition = obj.getBoundingClientRect(); - return {'x': objPosition.left, 'y': objPosition.top}; + return {'x': objPosition.left + window.pageXOffset, 'y': objPosition.top + window.pageYOffset}; }; |