Consistently places menu on maths elements by adding scroll offset.

This commit is contained in:
zorkow 2015-09-01 23:12:46 +01:00
parent 0922aa2ebc
commit 74c2b46da5

View File

@ -305,9 +305,11 @@
if (!parent) { if (!parent) {
var node = MENU.CurrentNode() || event.target; var node = MENU.CurrentNode() || event.target;
if (!x && !y && node) { if (!x && !y && node) {
var offsetX = window.pageXOffset || document.documentElement.scrollLeft;
var offsetY = window.pageYOffset || document.documentElement.scrollTop;
var rect = node.getBoundingClientRect(); var rect = node.getBoundingClientRect();
x = (rect.right + rect.left) / 2; x = (rect.right + rect.left) / 2 + offsetX;
y = (rect.bottom + rect.top) / 2; y = (rect.bottom + rect.top) / 2 + offsetY;
} }
if (x + menu.offsetWidth > document.body.offsetWidth - this.margin) if (x + menu.offsetWidth > document.body.offsetWidth - this.margin)
{x = document.body.offsetWidth - menu.offsetWidth - this.margin} {x = document.body.offsetWidth - menu.offsetWidth - this.margin}