@@ -5,6 +5,7 @@ export interface SwipeConfig {
55 minSwipeDistance : number ;
66 maxSwipeTime : number ;
77 preventScroll : boolean ;
8+ excludeSelectors ?: string [ ] ; // Seletores CSS de elementos a serem excluídos
89}
910
1011export interface SwipeCallbacks {
@@ -23,7 +24,8 @@ interface TouchPoint {
2324const DEFAULT_CONFIG : SwipeConfig = {
2425 minSwipeDistance : 50 , // Minimum distance in pixels for a valid swipe
2526 maxSwipeTime : 300 , // Maximum time in ms for a valid swipe
26- preventScroll : true // Prevent vertical scrolling during horizontal swipes
27+ preventScroll : true , // Prevent vertical scrolling during horizontal swipes
28+ excludeSelectors : [ ] // Selectors to exclude from swipe detection
2729} ;
2830
2931export function setupSwipeGestures (
@@ -45,6 +47,18 @@ export function setupSwipeGestures(
4547 }
4648
4749 function handleTouchStart ( event : TouchEvent ) {
50+ // Check if touch started on an excluded element
51+ if ( finalConfig . excludeSelectors && finalConfig . excludeSelectors . length > 0 ) {
52+ const target = event . target as HTMLElement ;
53+ for ( const selector of finalConfig . excludeSelectors ) {
54+ if ( target . closest ( selector ) ) {
55+ // Touch started on excluded element, ignore this gesture
56+ startTouch = null ;
57+ return ;
58+ }
59+ }
60+ }
61+
4862 startTouch = getTouchPoint ( event ) ;
4963 isHorizontalSwipe = false ;
5064 callbacks . onSwipeStart ?.( event ) ;
0 commit comments