Shortlist / frontend /src /components /landing /smooth-scroll.tsx
Eren-Sama
Initial commit — full-stack AI portfolio architect
53e1531
"use client";
import { useEffect, useRef } from "react";
import Lenis from "lenis";
export function SmoothScrollProvider({
children,
}: {
children: React.ReactNode;
}) {
const lenisRef = useRef<Lenis | null>(null);
useEffect(() => {
const lenis = new Lenis({
duration: 1.2,
easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
touchMultiplier: 2,
infinite: false,
});
lenisRef.current = lenis;
function raf(time: number) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
return () => {
lenis.destroy();
lenisRef.current = null;
};
}, []);
return <>{children}</>;
}