Files
whispering-tree/lib/useLenisScroll.js

26 lines
491 B
JavaScript
Raw Normal View History

2025-11-10 17:10:34 +05:30
"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}</>;
}