Scaffold SSR site with CMS/blog/gallery/SEO admin and deploy configs for montech.ir. Co-authored-by: Cursor <cursoragent@cursor.com>
20 lines
466 B
TypeScript
20 lines
466 B
TypeScript
import Lenis from "lenis";
|
|
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
if (!import.meta.client) return;
|
|
const lenis = new Lenis({ lerp: 0.09, smoothWheel: true });
|
|
let raf = 0;
|
|
const loop = (time: number) => {
|
|
lenis.raf(time);
|
|
raf = requestAnimationFrame(loop);
|
|
};
|
|
raf = requestAnimationFrame(loop);
|
|
nuxtApp.hook("app:unmounted", () => {
|
|
cancelAnimationFrame(raf);
|
|
lenis.destroy();
|
|
});
|
|
return {
|
|
provide: { lenis },
|
|
};
|
|
});
|