Skip to content

Commit

Permalink
Fix multitouch
Browse files Browse the repository at this point in the history
  • Loading branch information
imkunet committed Mar 19, 2024
1 parent cb92cf8 commit 4a170e0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pages/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,15 @@ export default function Game() {
const touchDownHandler = (event: TouchEvent) => {
if (!inGame()) return;
event.preventDefault();
handleMove(event.touches[0]?.clientX || -1, event.touches[0]?.clientY || -1);
// to be honest i have no idea how this is implemented on browsers :)
if (event.touches[0] == undefined) {
handleMove(-1, -1);
} else {
for (const touch of event.touches) {
handleMove(touch.clientX, touch.clientY);
}
}

handleMouseDown();
};
boardElement.addEventListener('touchstart', touchDownHandler);
Expand Down

0 comments on commit 4a170e0

Please sign in to comment.