Refactor code structure for improved readability and maintainability

This commit is contained in:
2026-08-31 19:59:49 +08:00
parent 812c39782e
commit 37173cfbeb
11 changed files with 836 additions and 22 deletions
+33
View File
@@ -0,0 +1,33 @@
'use client';
import { useEffect } from 'react';
import Lenis from 'lenis';
import { scrollBus } from '@/lib/scrollBus';
export default function SmoothScroller() {
useEffect(() => {
const lenis = new Lenis({
lerp: 0.1,
smoothWheel: true,
});
lenis.on('scroll', (e: any) => {
scrollBus.current = e.scroll;
scrollBus.velocity = e.velocity;
scrollBus.progress = e.progress;
});
function raf(time: number) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
return () => {
lenis.destroy();
};
}, []);
return null;
}