mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 13:17:41 +00:00
Calculate mouse position including scroll of overflow elements (cannot rely on pageX/Y).
This commit is contained in:
@@ -121,20 +121,17 @@ Guacamole.Mouse = function(element) {
|
|||||||
e.returnValue = false;
|
e.returnValue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveMouse(pageX, pageY) {
|
function moveMouse(clientX, clientY) {
|
||||||
|
|
||||||
guac_mouse.currentState.x = pageX - element.offsetLeft;
|
guac_mouse.currentState.x = clientX - element.offsetLeft;
|
||||||
guac_mouse.currentState.y = pageY - element.offsetTop;
|
guac_mouse.currentState.y = clientY - element.offsetTop;
|
||||||
|
|
||||||
// This is all JUST so we can get the mouse position within the element
|
// This is all JUST so we can get the mouse position within the element
|
||||||
var parent = element.offsetParent;
|
var parent = element.offsetParent;
|
||||||
while (parent) {
|
while (parent) {
|
||||||
|
|
||||||
if (parent.offsetLeft)
|
guac_mouse.currentState.x -= parent.offsetLeft - parent.scrollLeft;
|
||||||
guac_mouse.currentState.x -= parent.offsetLeft;
|
guac_mouse.currentState.y -= parent.offsetTop - parent.scrollTop;
|
||||||
|
|
||||||
if (parent.offsetTop)
|
|
||||||
guac_mouse.currentState.y -= parent.offsetTop;
|
|
||||||
|
|
||||||
parent = parent.offsetParent;
|
parent = parent.offsetParent;
|
||||||
}
|
}
|
||||||
@@ -157,7 +154,7 @@ Guacamole.Mouse = function(element) {
|
|||||||
|
|
||||||
cancelEvent(e);
|
cancelEvent(e);
|
||||||
|
|
||||||
moveMouse(e.pageX, e.pageY);
|
moveMouse(e.clientX, e.clientY);
|
||||||
|
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user