Spaces:
Sleeping
Sleeping
axeronis commited on
Commit ·
5e92ba2
1
Parent(s): 315a354
fix: Improved swipe detection tolerance for natural (messy) hand movements
Browse files
frontend/components/ChatWindow.tsx
CHANGED
|
@@ -352,9 +352,13 @@ export function ChatWindow({
|
|
| 352 |
const moveX = moveEvent.touches[0].clientX
|
| 353 |
const moveY = moveEvent.touches[0].clientY
|
| 354 |
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 358 |
setIsMobileDrawerOpen(true)
|
| 359 |
document.removeEventListener('touchmove', handleTouchMove)
|
| 360 |
}
|
|
|
|
| 352 |
const moveX = moveEvent.touches[0].clientX
|
| 353 |
const moveY = moveEvent.touches[0].clientY
|
| 354 |
|
| 355 |
+
const diffX = startX - moveX
|
| 356 |
+
const diffY = Math.abs(startY - moveY)
|
| 357 |
+
|
| 358 |
+
// Prioritize horizontal movement (multiply X diff for tolerance)
|
| 359 |
+
// This allows diagonal swipes to count as horizontal if they have enough momentum
|
| 360 |
+
if (Math.abs(diffX) > diffY * 0.8) {
|
| 361 |
+
if (diffX > 40) { // Swipe left (open)
|
| 362 |
setIsMobileDrawerOpen(true)
|
| 363 |
document.removeEventListener('touchmove', handleTouchMove)
|
| 364 |
}
|