Skip to content

Commit 913d0de

Browse files
committed
Fix touch event not updating mouse coordinates
1 parent 3738e3b commit 913d0de

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/events/pointer.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -912,25 +912,25 @@ function pointer(p5, fn){
912912

913913
fn._updatePointerCoords = function (e) {
914914
if (this._curElement !== null) {
915-
const canvas = this._curElement.elt;
916-
const sx = canvas.scrollWidth / this.width || 1;
917-
const sy = canvas.scrollHeight / this.height || 1;
915+
const canvas = this._curElement.elt;
916+
const sx = canvas.scrollWidth / this.width || 1;
917+
const sy = canvas.scrollHeight / this.height || 1;
918918

919-
if (e.pointerType == 'touch') {
919+
if (e.pointerType == 'touch') {
920920
const touches = [];
921921
for (const touch of this._activePointers.values()) {
922-
touches.push(getTouchInfo(canvas, sx, sy, touch));
922+
touches.push(getTouchInfo(canvas, sx, sy, touch));
923923
}
924924
this.touches = touches;
925-
} else {
926-
const mousePos = getMouseInfo(canvas, sx, sy, e);
927-
this.movedX = e.movementX || 0;
928-
this.movedY = e.movementY || 0;
929-
this.mouseX = mousePos.x;
930-
this.mouseY = mousePos.y;
931-
this.winMouseX = mousePos.winX;
932-
this.winMouseY = mousePos.winY;
933-
}
925+
}
926+
927+
const mousePos = getMouseInfo(canvas, sx, sy, e);
928+
this.movedX = e.movementX || 0;
929+
this.movedY = e.movementY || 0;
930+
this.mouseX = mousePos.x;
931+
this.mouseY = mousePos.y;
932+
this.winMouseX = mousePos.winX;
933+
this.winMouseY = mousePos.winY;
934934

935935
if (!this._hasMouseInteracted) {
936936
this._updateMouseCoords();

0 commit comments

Comments
 (0)