From 0e320470da900af399349a6d0d33b44707ef1d0f Mon Sep 17 00:00:00 2001
From: Percen <21pesi1bif@hft-stuttgart.de>
Date: Sat, 14 Dec 2024 16:02:07 +0000
Subject: [PATCH] Update public/index.html

---
 public/index.html | 31 +++++++++++++++----------------
 1 file changed, 15 insertions(+), 16 deletions(-)

diff --git a/public/index.html b/public/index.html
index 4711783..65b5cd6 100644
--- a/public/index.html
+++ b/public/index.html
@@ -30,7 +30,6 @@
     let currentModel = null;
     let scene, camera, hitTestSource;
     let hitTestResults = [];
-    let isSwipe = false;
 
     async function activateXR() {
       const canvas = document.createElement('canvas');
@@ -101,30 +100,30 @@
     }
 
     // Touch-Logik zur Unterscheidung zwischen Swipe und Tap
-    let startX = 0, endX = 0, isSwiping = false;
-    const threshold = 50;
+    let startX = 0, startY = 0, endX = 0, endY = 0;
+    const swipeThreshold = 50; // Minimale Swipe-Distanz
 
     document.body.addEventListener('touchstart', (e) => {
       startX = e.touches[0].clientX;
-      isSwiping = false;
+      startY = e.touches[0].clientY;
     });
 
-    document.body.addEventListener('touchmove', (e) => {
-      const moveX = e.touches[0].clientX;
-      if (Math.abs(moveX - startX) > threshold) {
-        isSwiping = true;
-        if (moveX > startX) {
+    document.body.addEventListener('touchend', (e) => {
+      endX = e.changedTouches[0].clientX;
+      endY = e.changedTouches[0].clientY;
+
+      const deltaX = endX - startX;
+      const deltaY = endY - startY;
+
+      // Unterscheidung zwischen Swipe und Tap
+      if (Math.abs(deltaX) > swipeThreshold) {
+        if (deltaX > 0) {
           switchModel('next');
         } else {
           switchModel('previous');
         }
-        startX = moveX; // Verhindert mehrfaches Swipen bei einem langen Touchmove
-      }
-    });
-
-    document.body.addEventListener('touchend', () => {
-      if (!isSwiping) {
-        placeModel();
+      } else if (Math.abs(deltaY) < swipeThreshold) {
+        placeModel(); // Nur platzieren, wenn keine große Bewegung erkannt wurde
       }
     });
 
-- 
GitLab