since3-website/modules/shared/ui/components/smooth-scroll.tsx
2026-09-25 00:45:33 +02:00

31 lines
707 B
TypeScript

"use client"
import { useEffect } from "react"
import Lenis from "lenis"
import { onIntroEnd } from "@/modules/shared/lib/intro"
/** Inertia scrolling for the whole page. Renders nothing. */
export function SmoothScroll() {
useEffect(() => {
if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return
const lenis = new Lenis({
autoRaf: true,
lerp: 0.09,
// Same-page anchor links scroll smoothly too
anchors: { offset: 0 },
})
// Hold the page still while the preloader plays
lenis.stop()
const cleanupIntro = onIntroEnd(() => lenis.start())
return () => {
cleanupIntro()
lenis.destroy()
}
}, [])
return null
}