From 12fe9ebb9640d22f37579a6e79542a94c48b3b3c Mon Sep 17 00:00:00 2001 From: Jeremy White Date: Thu, 18 Apr 2013 13:04:38 -0500 Subject: [PATCH] Use document.documentElement.scrollXXX if document.body.scrollXXX is not present. Provides compatibility for IE10. --- spicemsg.js | 7 +++++-- 1 file 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; }