Make Util.getPosition be relative to page
Commit 5108c4635c
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.
This commit is contained in:
parent
20d3fb6665
commit
7e54fb93dd
|
@ -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};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue