Skip to content

Commit

Permalink
Fix Mobile Touch Events
Browse files Browse the repository at this point in the history
Switches `Mouse` events for `Pointer` events, which should automagically make them work on both desktop and mobile browsers.
  • Loading branch information
zalo authored Jan 6, 2025
1 parent 5df1208 commit 8ae077d
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions demos/web-editor/web/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,24 @@ class App {
scene.canvas.addEventListener("contextmenu", (event) => {
event.preventDefault();
});
scene.canvas.addEventListener("mousedown", (event) => {
scene.canvas.addEventListener("pointerdown", (event) => {
event.preventDefault();
if (event.button === 0) {
scene.beginTranslate(event);
} else if (event.button === 2) {
scene.beginRotate(event);
}
});
window.addEventListener("mouseup", (event) => {
}, { passive: false });
window.addEventListener("pointerup", (event) => {
event.preventDefault();
scene.endDrag();
});
window.addEventListener("mousemove", (event) => {
}, { passive: false });
window.addEventListener("pointermove", (event) => {
event.preventDefault();
if (scene.drag(event)) {
requestRedraw();
}
});
}, { passive: false });
this.scene = scene;

// Hot-patch the gyroid script to be eval (instead of exec) flavored
Expand Down

0 comments on commit 8ae077d

Please sign in to comment.