Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/landing/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ The landing design lives in `design/landing.pen` (frame `Landing v0.1`, plus the

Next.js 16 App Router + Tailwind 4, same pinned versions as `apps/fe`. Bun 1.3.9 (`npx -y bun@1.3.9 …` works without a global install).

Smooth scrolling: `lenis` 1.3.27 (Axel, 13 Nov), in `components/SmoothScroll.tsx`. It drives the page's own scroll (no wrapper), runs on GSAP's ticker and calls `ScrollTrigger.update` on every scroll, so the pins and the scrubbed approvals scene stay in step (checked: the scene at the same scrollY looks the same with and without it, mean pixel difference 0.2 of 255). Touch keeps the device's own scrolling; reduced motion gets no Lenis. It is stopped until the page loader lifts (`hn:reveal`). It sits on `window.__lenis`, so code that jumps (`PageLoader`'s in-page links, `OverlayScrollbar`'s drag) calls `lenis.scrollTo(y, { immediate: true })` instead of `window.scrollTo`, or Lenis would glide on to where it was heading. `anchors` is off: `PageLoader` handles in-page links.

```sh
bun install
bun run dev # http://localhost:3100 (apps/fe keeps 3000)
Expand Down
2 changes: 2 additions & 0 deletions apps/landing/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Geist } from "next/font/google";
import "./globals.css";
import { OverlayScrollbar } from "@/components/OverlayScrollbar";
import { PageLoader } from "@/components/PageLoader";
import { SmoothScroll } from "@/components/SmoothScroll";

const geist = Geist({ subsets: ["latin"], variable: "--font-geist" });

Expand Down Expand Up @@ -32,6 +33,7 @@ export default function RootLayout({ children }: { children: React.ReactNode })
<body>
<PageLoader />
<OverlayScrollbar />
<SmoothScroll />
{children}
</body>
</html>
Expand Down
3 changes: 3 additions & 0 deletions apps/landing/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions apps/landing/components/OverlayScrollbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,11 @@ export function OverlayScrollbar() {
const total = document.documentElement.scrollHeight;
const travel = view - el.offsetHeight;
if (travel <= 0) return;
// Thumb pixels to page pixels; "instant", since the page scrolls smoothly by default.
// Thumb pixels to page pixels, at once: through Lenis when it runs (SmoothScroll), else "instant".
const top = d.startScroll + ((e.clientY - d.startY) / travel) * (total - view);
window.scrollTo({ top, behavior: "instant" });
const lenis = (window as unknown as { __lenis?: { scrollTo: (y: number, o: { immediate: boolean }) => void } }).__lenis;
if (lenis) lenis.scrollTo(top, { immediate: true });
else window.scrollTo({ top, behavior: "instant" });
};
const onUp = () => {
drag.current = null;
Expand Down
5 changes: 4 additions & 1 deletion apps/landing/components/PageLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,10 @@ export function PageLoader() {
requestAnimationFrame(() => requestAnimationFrame(() => setPhase("cover")));
setTimeout(() => {
const y = targetY(hash) ?? 0;
window.scrollTo({ top: y, behavior: "instant" as ScrollBehavior });
// Through Lenis when it runs (SmoothScroll), or it would glide on to where it was heading.
const lenis = (window as unknown as { __lenis?: { scrollTo: (y: number, o: { immediate: boolean; force: boolean }) => void } }).__lenis;
if (lenis) lenis.scrollTo(y, { immediate: true, force: true });
else window.scrollTo({ top: y, behavior: "instant" as ScrollBehavior });
// No "#…" in the address (Ancung, 13 Nov): the link still works, the bar stays hellonear.xyz.
history.replaceState(null, "", location.pathname + location.search);
// let the scroll-driven scenes settle and the images there decode, then lift
Expand Down
38 changes: 38 additions & 0 deletions apps/landing/components/SmoothScroll.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"use client";

import { useEffect } from "react";
import gsap from "gsap";
import { ScrollTrigger } from "gsap/ScrollTrigger";
import Lenis from "lenis";
import "lenis/dist/lenis.css";

gsap.registerPlugin(ScrollTrigger);

// Smooth wheel scrolling with Lenis (Axel, 13 Nov). It drives the page's own scroll (no wrapper), so
// position: sticky, the GSAP pins and every scrollY reader keep working. Lenis runs on GSAP's ticker
// and tells ScrollTrigger on every scroll, so the scrubbed approvals scene and the pins move in step
// with it. Touch keeps the device's own scrolling (Lenis' default). Reduced motion: no Lenis.
// Held still while the page loader covers the page, as the loader locks the scroll.
export function SmoothScroll() {
useEffect(() => {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
const lenis = new Lenis({ autoRaf: false, anchors: false });
(window as unknown as { __lenis?: Lenis }).__lenis = lenis;
lenis.on("scroll", ScrollTrigger.update);
const tick = (time: number) => lenis.raf(time * 1000);
gsap.ticker.add(tick);
gsap.ticker.lagSmoothing(0);

const revealed = (window as unknown as { __hnRevealed?: boolean }).__hnRevealed;
if (!revealed) lenis.stop();
const start = () => lenis.start();
window.addEventListener("hn:reveal", start);
return () => {
window.removeEventListener("hn:reveal", start);
gsap.ticker.remove(tick);
lenis.destroy();
delete (window as unknown as { __lenis?: Lenis }).__lenis;
};
}, []);
return null;
}
1 change: 1 addition & 0 deletions apps/landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"gsap": "3.15.1",
"lenis": "1.3.27",
"next": "16.4.4",
"react": "19.3.1",
"react-dom": "19.3.1",
Expand Down
Loading