Commit 7e54fb93 authored by Solly Ross's avatar Solly Ross

Make Util.getPosition be relative to page

Commit 5108c463 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.
parent 20d3fb66
...@@ -436,7 +436,7 @@ Util.load_scripts = function (files) { ...@@ -436,7 +436,7 @@ Util.load_scripts = function (files) {
Util.getPosition = function(obj) { Util.getPosition = function(obj) {
"use strict"; "use strict";
var objPosition = obj.getBoundingClientRect(); var objPosition = obj.getBoundingClientRect();
return {'x': objPosition.left, 'y': objPosition.top}; return {'x': objPosition.left + window.pageXOffset, 'y': objPosition.top + window.pageYOffset};
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment