Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: add swipe to open nav menu on mobiles

thecodrrdc8ea2d73f93
diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.js
index 7bc3a4f53..abbf7b3fe 100644
--- a/apps/web/src/components/navigation-menu/index.js
+++ b/apps/web/src/components/navigation-menu/index.js
@@ -58,11 +58,35 @@ function NavigationMenu(props) {
setSelectedRoute(path);
}, [path]);
+ useEffect(() => {
+ if (!isMobile) return;
+ const app = document.getElementById("app");
+ let startX = 0;
+ app.ontouchstart = function (event) {
+ startX = event.touches[0].pageX;
+ };
+
+ app.ontouchmove = function (event) {
+ let currentX = event.touches[0].pageX;
+ if (currentX - startX > 50) {
+ toggleSideMenu(true);
+ startX = currentX;
+ } else if (currentX - startX < -50) {
+ toggleSideMenu(false);
+ startX = currentX;
+ }
+ };
+ }, [toggleSideMenu, isMobile]);
+
return (
<Animated.Flex
+ id="navigationmenu"
flexDirection="column"
justifyContent="space-between"
- initial={{ opacity: 1, x: isMobile ? -500 : 0 }}
+ initial={{
+ opacity: 1,
+ x: isMobile ? -500 : 0,
+ }}
animate={{
opacity: isFocusMode ? 0 : 1,
visibility: isFocusMode ? "hidden" : "visible",