From cc9ae32777d4ab06438659a0218b4ced34914184 Mon Sep 17 00:00:00 2001 From: hippoz Date: Thu, 28 Oct 2021 04:04:22 +0300 Subject: [PATCH] hacky solution to fix cursor from rubberbanding when starting a new touch --- public/index.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/public/index.html b/public/index.html index ce52ef4..cf9cf63 100644 --- a/public/index.html +++ b/public/index.html @@ -103,17 +103,26 @@ currentX: 0, currentY: 0, lastCheckedX: 0, - lastCheckedY: 0 + lastCheckedY: 0, + shouldResetTouch: false, } touchpad.addEventListener("touchmove", (event) => { movementState.currentX = event.touches[0].clientX; movementState.currentY = event.touches[0].clientY; + if (movementState.shouldResetTouch) { + movementState.shouldResetTouch = false; + movementState.lastCheckedX = movementState.currentX; + movementState.lastCheckedY = movementState.currentY; + } const deltaX = movementState.currentX - movementState.lastCheckedX; const deltaY = movementState.currentY - movementState.lastCheckedY; movementState.lastCheckedX = movementState.currentX; movementState.lastCheckedY = movementState.currentY; connection.sendMessage("r", [deltaX, deltaY]); }); + touchpad.addEventListener("touchend", () => { + movementState.shouldResetTouch = true; + }); }