Chat List: Fix swipe gesture spoils scroll

This commit is contained in:
Alexander Zinchuk 2021-08-21 14:35:12 +03:00
parent ea20abb74b
commit 3c9ad43581

View File

@ -45,6 +45,7 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) {
let captureEvent: MouseEvent | RealTouchEvent | undefined; let captureEvent: MouseEvent | RealTouchEvent | undefined;
let hasMoved = false; let hasMoved = false;
let hasSwiped = false; let hasSwiped = false;
let initialSwipeAxis: TSwipeAxis | undefined;
function onCapture(e: MouseEvent | RealTouchEvent) { function onCapture(e: MouseEvent | RealTouchEvent) {
if (options.excludedClosestSelector && ( if (options.excludedClosestSelector && (
@ -194,6 +195,13 @@ export function captureEvents(element: HTMLElement, options: CaptureOptions) {
return false; 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!); return processSwipe(e, axis, dragOffsetX, dragOffsetY, options.onSwipe!);
} }