From 3b5f140d218b70154314df60eaa77b0006aa3436 Mon Sep 17 00:00:00 2001 From: me Date: Tue, 5 May 2026 21:43:47 +0530 Subject: [PATCH] feat: use ReactLenis and simplify motion animations in Home page --- frontend/src/App.tsx | 8 +- frontend/src/pages/Home.tsx | 619 ++++++++++++++++++------------------ 2 files changed, 311 insertions(+), 316 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 26b0d9c..c54c4e9 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,11 +1,5 @@ import { lazy, Suspense, useEffect, useRef } from "react"; -import { - BrowserRouter, - Navigate, - Route, - Routes, - ScrollRestoration, -} from "react-router-dom"; +import { BrowserRouter, Navigate, Route, Routes } from "react-router-dom"; import { ProtectedRoute, PublicRoute } from "./components/RouteGuards"; import SplashScreen from "./components/SplashScreen"; import { ROUTES } from "./config/routes"; diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index 69c0053..697f8d7 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -1,9 +1,9 @@ import { InfoIcon } from "@phosphor-icons/react"; +import { ReactLenis } from "lenis/react"; import { motion, useMotionValueEvent, useScroll, - useSpring, useTransform, } from "motion/react"; import { useRef, useState } from "react"; @@ -16,14 +16,9 @@ import { formatDate } from "../utils/dateFormat.ts"; export default function Home() { const sectionContainer1 = useRef(null); - const { scrollYProgress: section1ScrollProgress } = useScroll({ + const { scrollYProgress } = useScroll({ target: sectionContainer1, }); - const smoothProgress1 = useSpring(section1ScrollProgress, { - stiffness: 100, - damping: 30, - restDelta: 0.001, - }); const [isEnvelopeFlipped, setIsEnvelopeFlipped] = useState(true); const [flapOpen, setFlapOpen] = useState(false); const [recipient, setRecipient] = useState("someone dear"); @@ -31,7 +26,7 @@ export default function Home() { const navigate = useNavigate(); - useMotionValueEvent(section1ScrollProgress, "change", (latestScrollValue) => { + useMotionValueEvent(scrollYProgress, "change", (latestScrollValue) => { if (latestScrollValue > 0.54) { setFlapOpen(false); } else { @@ -55,342 +50,348 @@ export default function Home() { }); return ( -
-
- {/* Intro */} - -

- You've been carrying something -

-

- unsaid -

-
- - -
- and that's okay... -
-
- {/* pi. ku. */} - - + +
+
+ {/* Intro */} - is a{" "} - - safe space - - ,
- - where you can - +

+ You've been carrying something +

+

+ unsaid +

- -
- +
+ and that's okay... +
+ + {/* pi. ku. */} + - pen down your unsaid words into{" "} - - letters - - . -
- {/* Seal */} - - seal it{" "} - - secure - {" "} - and{" "} - - private - - . - - {/* Send / vault */} - - send it to{" "} - + - someone dear - - + safe space + + ,
+ + where you can + + + + +
+ + pen down your unsaid words into{" "} + + letters + + . + + {/* Seal */} + + seal it{" "} + + secure + {" "} + and{" "} + + private + + . + + {/* Send / vault */} + + send it to{" "} - {" "} - or{" "} + someone dear - - yourself in the future - - . - - - {/* Burn */} - - and even burn it to - release the burden. - - {/* Outro */} - - You've been carrying it long enough. - - {/* CTA */} - - - - -
+ You've been carrying it long enough. +
+ {/* CTA */} + + + + +
-
- -
-
-
- letter +
+ +
+
+
+ letter +
-
- - {/* Envelope */} - - {}} - isFlip={isEnvelopeFlipped} - openFlap={flapOpen} + + {/* Envelope */} + + {}} + isFlip={isEnvelopeFlipped} + openFlap={flapOpen} + /> + + {/* Saajan */} + + + + {/* Orb */} + - - {/* Saajan */} - - - - {/* Orb */} - -
+
+
-
-
+
+ ); }