mirror of
https://github.com/Since-3/since3-website.git
synced 2026-10-12 19:51:16 +00:00
31 lines
707 B
TypeScript
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
|
|
}
|