mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-13 01:02:25 -06:00
refac
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user