Spaces:
Running
Running
Download bioai-platform/frontend/src/components/SmoothScrollProvider.tsx from Samad14/bio-nexus-api: direct link, hf CLI and curl.
- Browser
- Download file 901 Bytes
-
https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/components/SmoothScrollProvider.tsx
- Command line
-
hf download hf://spaces/Samad14/bio-nexus-api/bioai-platform/frontend/src/components/SmoothScrollProvider.tsx
-
curl -L -o SmoothScrollProvider.tsx https://huggingface.co/spaces/Samad14/bio-nexus-api/resolve/main/bioai-platform/frontend/src/components/SmoothScrollProvider.tsx
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}</>; | |
| } | |