diff --git a/src/util/captureEvents.ts b/src/util/captureEvents.ts index ee77abf3b..8d4e8a8aa 100644 --- a/src/util/captureEvents.ts +++ b/src/util/captureEvents.ts @@ -45,6 +45,7 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) { let captureEvent: MouseEvent | RealTouchEvent | undefined; let hasMoved = false; let hasSwiped = false; + let initialSwipeAxis: TSwipeAxis | undefined; function onCapture(e: MouseEvent | RealTouchEvent) { if (options.excludedClosestSelector && ( @@ -194,6 +195,13 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) { return false; } + if (!initialSwipeAxis) { + initialSwipeAxis = axis; + } else if (initialSwipeAxis !== axis) { + // Prevent horizontal swipe after vertical to prioritize scroll + return false; + } + return processSwipe(e, axis, dragOffsetX, dragOffsetY, options.onSwipe!); }