From 5dfeeadbb87af9bdf0761c27fc2eba08c44cbfe6 Mon Sep 17 00:00:00 2001 From: Jip Fr Date: Fri, 14 Apr 2023 20:03:11 +0200 Subject: [PATCH] fix(popouts): fix touch on scroll areas being weird --- .../positions/FloatingCardMobilePosition.tsx | 17 +++++++++++++++-- src/setup/index.css | 13 ++++++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/components/popout/positions/FloatingCardMobilePosition.tsx b/src/components/popout/positions/FloatingCardMobilePosition.tsx index 059f6667..7f890051 100644 --- a/src/components/popout/positions/FloatingCardMobilePosition.tsx +++ b/src/components/popout/positions/FloatingCardMobilePosition.tsx @@ -21,8 +21,21 @@ export function FloatingCardMobilePosition(props: MobilePositionProps) { })); const bind = useDrag( - ({ last, velocity: [, vy], direction: [, dy], movement: [, my] }) => { + ({ + last, + velocity: [, vy], + direction: [, dy], + movement: [, my], + ...event + }) => { if (closing.current) return; + + const isInScrollable = (event.target as HTMLDivElement).closest( + ".overflow-y-auto" + ); + // console.log(my); + if (isInScrollable) return; // Don't attempt to swipe the thing away if it's a scroll area unless the scroll area is at the top and the user is swiping down + const height = cardRect?.height ?? 0; if (last) { // if past half height downwards @@ -69,7 +82,7 @@ export function FloatingCardMobilePosition(props: MobilePositionProps) { return (