From 73161ecfa599e6e227f20e68d14868504f313331 Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Mon, 6 Jan 2025 15:16:43 -0800 Subject: [PATCH 1/3] Fix Mobile Touch Events Switches `Mouse` events for `Pointer` events, which should automagically make them work on both desktop and mobile browsers. --- demos/web-editor/web/src/index.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/demos/web-editor/web/src/index.ts b/demos/web-editor/web/src/index.ts index 9f593bfc..e5430524 100644 --- a/demos/web-editor/web/src/index.ts +++ b/demos/web-editor/web/src/index.ts @@ -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 From 06908cd014cdb1bc07c3b7864da09ea8d55d2db8 Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Mon, 6 Jan 2025 15:25:03 -0800 Subject: [PATCH 2/3] Prevent weird default browser gestures --- demos/web-editor/web/src/index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/demos/web-editor/web/src/index.html b/demos/web-editor/web/src/index.html index ee6db76c..450359bf 100644 --- a/demos/web-editor/web/src/index.html +++ b/demos/web-editor/web/src/index.html @@ -26,6 +26,9 @@ max-height: 512px; outline: 1px solid #bbb; margin-bottom: 12px; + user-select: none; + pointer-events: none; + touch-action: none; } span#status { display: block; From 2f0b56ab0e6dc1c4987b348a827c631be1875de4 Mon Sep 17 00:00:00 2001 From: Johnathon Selstad Date: Mon, 6 Jan 2025 16:23:33 -0800 Subject: [PATCH 3/3] Remove Overzealous Voodoo --- demos/web-editor/web/src/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/demos/web-editor/web/src/index.html b/demos/web-editor/web/src/index.html index 450359bf..e09f9726 100644 --- a/demos/web-editor/web/src/index.html +++ b/demos/web-editor/web/src/index.html @@ -27,7 +27,6 @@ outline: 1px solid #bbb; margin-bottom: 12px; user-select: none; - pointer-events: none; touch-action: none; } span#status {