Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/components/Trackpad/TouchArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface TouchAreaProps {
onTouchStart: (e: React.TouchEvent) => void
onTouchMove: (e: React.TouchEvent) => void
onTouchEnd: (e: React.TouchEvent) => void
onTouchCancel: (e: React.TouchEvent) => void
}
}

Expand All @@ -32,6 +33,7 @@ export const TouchArea: React.FC<TouchAreaProps> = ({
onTouchStart={handleStart}
onTouchMove={handlers.onTouchMove}
onTouchEnd={handlers.onTouchEnd}
onTouchCancel={handlers.onTouchCancel}
onMouseDown={handlePreventFocus}
>
<div className="text-neutral-600 text-center pointer-events-none">
Expand Down
29 changes: 29 additions & 0 deletions src/hooks/useTrackpadGesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,41 @@ export const useTrackpadGesture = (
}
}

const handleTouchCancel = () => {
// Clear all active touches
ongoingTouches.current.clear()

// Reset gesture state
setIsTracking(false)
moved.current = false
releasedCount.current = 0

// Reset pinch state
lastPinchDist.current = null
pinching.current = false

// Clear dragging timeout if exists
if (draggingTimeout.current) {
clearTimeout(draggingTimeout.current)
draggingTimeout.current = null
}

// Release drag if active
if (dragging.current) {
dragging.current = false
}

// 🔥 Safety: ensure no stuck mouse state
send({ type: "click", button: "left", press: false })
}

return {
isTracking,
handlers: {
onTouchStart: handleTouchStart,
onTouchMove: handleTouchMove,
onTouchEnd: handleTouchEnd,
onTouchCancel: handleTouchCancel,
},
}
}
Loading