diff --git a/src/lib/components/layout/Sidebar.svelte b/src/lib/components/layout/Sidebar.svelte index 9537eed9b..33334b38b 100644 --- a/src/lib/components/layout/Sidebar.svelte +++ b/src/lib/components/layout/Sidebar.svelte @@ -45,6 +45,31 @@ show = true; } await chats.set(await getChatList(localStorage.token)); + + let touchstartX = 0; + let touchendX = 0; + + function checkDirection() { + const screenWidth = window.innerWidth; + const swipeDistance = Math.abs(touchendX - touchstartX); + if (swipeDistance >= screenWidth / 4) { + if (touchendX < touchstartX) { + show = false; + } + if (touchendX > touchstartX) { + show = true; + } + } + } + + document.addEventListener('touchstart', (e) => { + touchstartX = e.changedTouches[0].screenX; + }); + + document.addEventListener('touchend', (e) => { + touchendX = e.changedTouches[0].screenX; + checkDirection(); + }); }); // Helper function to fetch and add chat content to each chat @@ -706,6 +731,7 @@