diff options
-rw-r--r-- | spicemsg.js | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/spicemsg.js b/spicemsg.js index 31e54a0..365fdf7 100644 --- a/spicemsg.js +++ b/spicemsg.js @@ -639,8 +639,11 @@ function SpiceMsgcMousePosition(sc, e) this.buttons_state = sc.buttons_state; if (e) { - this.x = e.clientX - sc.display.surfaces[sc.display.primary_surface].canvas.offsetLeft + document.body.scrollLeft; - this.y = e.clientY - sc.display.surfaces[sc.display.primary_surface].canvas.offsetTop + document.body.scrollTop; + var scrollTop = document.body.scrollTop || document.documentElement.scrollTop; + var scrollLeft = document.body.scrollLeft || document.documentElement.scrollLeft; + + this.x = e.clientX - sc.display.surfaces[sc.display.primary_surface].canvas.offsetLeft + scrollLeft; + this.y = e.clientY - sc.display.surfaces[sc.display.primary_surface].canvas.offsetTop + scrollTop; sc.mousex = this.x; sc.mousey = this.y; } |