26 lines
491 B
JavaScript
26 lines
491 B
JavaScript
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import Lenis from "@studio-freight/lenis";
|
|
|
|
export default function SmoothScrollProvider({ children }) {
|
|
useEffect(() => {
|
|
const lenis = new Lenis({
|
|
smooth: true,
|
|
duration: 1.2, // Adjust the scroll speed
|
|
});
|
|
|
|
function raf(time) {
|
|
lenis.raf(time);
|
|
requestAnimationFrame(raf);
|
|
}
|
|
requestAnimationFrame(raf);
|
|
|
|
return () => {
|
|
lenis.destroy();
|
|
};
|
|
}, []);
|
|
|
|
return <>{children}</>;
|
|
}
|