From 66901b32d358ef0112ac7ea76d60af0fc0aabe3e Mon Sep 17 00:00:00 2001 From: Christian Aistleitner Date: Fri, 24 Nov 2023 12:49:20 +0100 Subject: [PATCH] Fix `InputManager.onTouchMove` to work on scrolled-down pages `document.elementFromPoint` expects plain viewport coordinates [1], while we used `page[XY]`, which are viewport coordinates with added scroll offsets [2]. So on pages where no scrolling had yet occurred, `InputManager.onTouchMove` worked as expected. But as soon as one scrolled down/right on the page, the element detection was off by the scroll offset. We switch from `page[XY]` to `client[XY]` which are plain viewport coordinates [3] and thereby make element detection work also on pages that have been scrolled around. [1] https://drafts.csswg.org/cssom-view/#dom-document-elementfrompoint [2] https://w3c.github.io/touch-events/#dom-touch-pagex [3] https://w3c.github.io/touch-events/#dom-touch-clientx --- src/input/InputManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/input/InputManager.js b/src/input/InputManager.js index 80377a3c2..3f19a765d 100644 --- a/src/input/InputManager.js +++ b/src/input/InputManager.js @@ -614,7 +614,7 @@ var InputManager = new Class({ if (pointer.active && pointer.identifier === changedTouch.identifier) { - var element = document.elementFromPoint(changedTouch.pageX, changedTouch.pageY); + var element = document.elementFromPoint(changedTouch.clientX, changedTouch.clientY); var overCanvas = element === this.canvas; if (!this.isOver && overCanvas)