This commit is contained in:
Timothy Jaeryang Baek
2026-08-11 17:44:34 -06:00
parent 9c21d4ed3b
commit ab41dcc487
@@ -62,11 +62,34 @@
return (
target instanceof Element &&
!!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) => {
if (scrollLocked === locked || typeof document === 'undefined') {
return;
@@ -190,6 +213,11 @@
return;
}
if (absX > absY && canScrollHorizontally(e.target, dx)) {
cancelSwipe();
return;
}
if (absY > absX || absX < absY * AXIS_RATIO) {
cancelSwipe();
return;