forked from open-webui/open-webui
Hide sidevar when screen is resized to less than 1024 pixels
This commit is contained in:
parent
f8f9f27ae8
commit
0c79ac0479
1 changed files with 12 additions and 5 deletions
|
@ -29,6 +29,7 @@
|
|||
import ArchiveBox from '../icons/ArchiveBox.svelte';
|
||||
import ArchivedChatsModal from './Sidebar/ArchivedChatsModal.svelte';
|
||||
|
||||
const BREAKPOINT = 1024;
|
||||
let show = false;
|
||||
let navElement;
|
||||
|
||||
|
@ -49,9 +50,7 @@
|
|||
let isEditing = false;
|
||||
|
||||
onMount(async () => {
|
||||
if (window.innerWidth > 1024) {
|
||||
show = true;
|
||||
}
|
||||
show = window.innerWidth > BREAKPOINT;
|
||||
await chats.set(await getChatList(localStorage.token));
|
||||
|
||||
let touchstartX = 0;
|
||||
|
@ -79,12 +78,20 @@
|
|||
checkDirection();
|
||||
};
|
||||
|
||||
const onResize = () => {
|
||||
if(show && window.innerWidth < BREAKPOINT) {
|
||||
show = false;
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('touchstart', onTouchStart);
|
||||
document.addEventListener('touchend', onTouchEnd);
|
||||
window.addEventListener('resize', onResize);
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('touchstart', onTouchStart);
|
||||
document.removeEventListener('touchend', onTouchEnd);
|
||||
document.removeEventListener('resize', onResize);
|
||||
};
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue