Spaces:
Sleeping

axeronis commited on
Commit
5e92ba2
·
1 Parent(s): 315a354

fix: Improved swipe detection tolerance for natural (messy) hand movements

Browse files
Files changed (1) hide show
  1. frontend/components/ChatWindow.tsx +7 -3
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
- // Check if it's horizontal swipe
356
- if (Math.abs(startX - moveX) > Math.abs(startY - moveY)) {
357
- if (startX - moveX > 50) { // Swipe left
 
 
 
 
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
  }