hacky solution to fix cursor from rubberbanding when starting a new touch
This commit is contained in:
parent
c56d83881a
commit
cc9ae32777
1 changed files with 10 additions and 1 deletions
|
@ -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;
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in a new issue