From 3c9ad43581be0e2fd7faa76bf8fba5bf43aa0ad1 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Sat, 21 Aug 2021 14:35:12 +0300 Subject: [PATCH] Chat List: Fix swipe gesture spoils scroll --- src/util/captureEvents.ts | 8 ++++++++ 1 file changed, 8 insertions(+) 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!); }