Skip to content

Commit

Permalink
Add swipe for list
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Jun 29, 2024
1 parent 92d1234 commit 36ad83a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Filesystem } from '@capacitor/filesystem';
import { App as NativeApp } from '@capacitor/app';
import { Preferences } from '@capacitor/preferences';
import { get } from 'idb-keyval';
import { createRoot } from 'react-dom/client';
Expand Down Expand Up @@ -59,12 +58,6 @@ async function load() {

registerCoreBlocks();
root.render(app({ selectedFolderURL, canUseNativeFilesystem }));

NativeApp.addListener('appStateChange', ({ isActive }) => {
if (!isActive) {
// save
}
});
}

load();
33 changes: 33 additions & 0 deletions src/list.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,39 @@ export default function Frame({ selectedFolderURL, setSelectedFolderURL }) {
);
}, []);

useEffect(() => {
if (isSidebarOpen) {
return;
}

let startTouchX = 0;

document.addEventListener('touchstart', handleTouchStart);
document.addEventListener('touchmove', handleTouchMove);

function handleTouchStart(event) {
startTouchX = event.touches[0].clientX;
}

function handleTouchMove(event) {
if (event.touches.length > 1) {
return;
}

const touchX = event.touches[0].clientX;
const deltaX = touchX - startTouchX;

if (deltaX > 50 && startTouchX < 20) {
setIsSidebarOpen(true);
}
}

return () => {
document.removeEventListener('touchstart', handleTouchStart);
document.removeEventListener('touchmove', handleTouchMove);
};
}, [isSidebarOpen, setIsSidebarOpen]);

useEffect(() => {
setItems([]);
setCurrentId();
Expand Down

0 comments on commit 36ad83a

Please sign in to comment.