'use client'; import { useEffect, useRef } from 'react'; import Lenis from 'lenis'; export default function SmoothScrollProvider({ children }: { children: React.ReactNode }) { const lenisRef = useRef(null); useEffect(() => { const lenis = new Lenis({ duration: 1.25, easing: (t: number) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), orientation: 'vertical', smoothWheel: true, wheelMultiplier: 0.9, touchMultiplier: 1.5, }); lenisRef.current = lenis; lenis.on('scroll', () => { window.dispatchEvent(new Event('scroll')); }); let rafId: number; function raf(time: number) { lenis.raf(time); rafId = requestAnimationFrame(raf); } rafId = requestAnimationFrame(raf); return () => { cancelAnimationFrame(rafId); lenis.destroy(); }; }, []); return <>{children}; }