This commit is contained in:
Timothy Jaeryang Baek committed 2026-08-11 17:44:34 -06:00
1 parent 9c21d4ed3b
commit ab41dcc487
1 file changed
+29 -1
@@ -62,11 +62,34 @@
return ( return (
target instanceof Element && target instanceof Element &&
!!target.closest( !!target.closest(
'input, textarea, select, button, [role="menu"], [contenteditable="true"], [data-sidebar-no-gesture]' 'input, textarea, select, [role="menu"], [contenteditable="true"], [data-sidebar-no-gesture]'
) )
); );
}; };
const canScrollHorizontally = (target: EventTarget | null, dx: number) => {
if (!(target instanceof Element) || dx === 0 || typeof window === 'undefined') {
return false;
}
let element: Element | null = target;
while (element && element !== document.documentElement && element !== document.body) {
const node = element as HTMLElement;
const overflowX = window.getComputedStyle(node).overflowX;
const isScrollable =
/(auto|scroll|overlay)/.test(overflowX) && node.scrollWidth > node.clientWidth + 1;
if (isScrollable) {
const maxScrollLeft = node.scrollWidth - node.clientWidth;
return dx > 0 ? node.scrollLeft > 0 : node.scrollLeft < maxScrollLeft - 1;
}
element = element.parentElement;
}
return false;
};
const setScrollLock = (locked: boolean) => { const setScrollLock = (locked: boolean) => {
if (scrollLocked === locked || typeof document === 'undefined') { if (scrollLocked === locked || typeof document === 'undefined') {
return; return;
@@ -190,6 +213,11 @@
return; return;
} }
if (absX > absY && canScrollHorizontally(e.target, dx)) {
cancelSwipe();
return;
}
if (absY > absX || absX < absY * AXIS_RATIO) { if (absY > absX || absX < absY * AXIS_RATIO) {
cancelSwipe(); cancelSwipe();
return; return;