bio-nexus-api / bioai-platform /frontend /src /components /SmoothScrollProvider.tsx
Samad14's picture
redesign: BioFlow AI void-dark theme — new landing page, dashboard, Three.js DNA helix, Lenis smooth scroll
627ac39
Raw History Blame Contribute Delete
901 Bytes
'use client';
import { useEffect, useRef } from 'react';
import Lenis from 'lenis';
export default function SmoothScrollProvider({ children }: { children: React.ReactNode }) {
const lenisRef = useRef<Lenis | null>(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}</>;
}