mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-11 20:05:19 +00:00
refac
This commit is contained in:
parent
b364cf43d3
commit
282c541427
1 changed files with 5 additions and 7 deletions
|
|
@ -378,14 +378,13 @@
|
|||
let isResizing = false;
|
||||
|
||||
let startWidth = 0;
|
||||
let startX = 0;
|
||||
let endX = 0;
|
||||
let startClientX = 0;
|
||||
|
||||
const resizeStartHandler = (e: MouseEvent) => {
|
||||
if ($mobile) return;
|
||||
isResizing = true;
|
||||
|
||||
startX = e.clientX;
|
||||
startClientX = e.clientX;
|
||||
startWidth = $sidebarWidth ?? 260;
|
||||
|
||||
document.body.style.userSelect = 'none';
|
||||
|
|
@ -399,8 +398,8 @@
|
|||
localStorage.setItem('sidebarWidth', String($sidebarWidth));
|
||||
};
|
||||
|
||||
const applyResize = () => {
|
||||
const dx = endX - startX;
|
||||
const resizeSidebarHandler = (endClientX) => {
|
||||
const dx = endClientX - startClientX;
|
||||
const newSidebarWidth = Math.min(MAX_WIDTH, Math.max(MIN_WIDTH, startWidth + dx));
|
||||
|
||||
sidebarWidth.set(newSidebarWidth);
|
||||
|
|
@ -622,8 +621,7 @@
|
|||
<svelte:window
|
||||
on:mousemove={(e) => {
|
||||
if (!isResizing) return;
|
||||
endX = e.clientX;
|
||||
applyResize();
|
||||
resizeSidebarHandler(e.clientX);
|
||||
}}
|
||||
on:mouseup={() => {
|
||||
resizeEndHandler();
|
||||
|
|
|
|||
Loading…
Reference in a new issue