Usage
Parameters
| Parameter | Type | Description |
|---|---|---|
func | (direction: string | null) => void | Optional callback when swipe is detected |
Return Value
| Property | Type | Description |
|---|---|---|
onTouchStart | (e: TouchEvent) => void | Touch start event handler |
onTouchMove | (e: TouchEvent) => void | Touch move event handler |
onTouchEnd | (e: TouchEvent) => void | Touch end event handler |
direction | "left" | "right" | null | Current swipe direction |
Features
- Minimum swipe distance threshold (50px) to prevent false positives
- Detects both left and right swipes
- Provides touch event handlers for easy integration
Examples
Dismissible Card
Carousel Navigation
Technical Details
- Minimum swipe distance: 50 pixels
- Directions detected:
"left","right", ornull(if swipe distance is insufficient) - The hook tracks touch position using
clientXcoordinates - Regular touch events (taps) are ignored due to the minimum distance threshold