Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(lenis): Add LenisProvider for smooth scrolling and update depend…
…encies
  • Loading branch information
arghyaxcodes committed Oct 29, 2025
commit 537c95b22b2ef836bb3dd6197ab00eac639d151a
3 changes: 3 additions & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"fumadocs-mdx": "11.7.0",
"fumadocs-ui": "15.6.5",
"latest": "^0.2.0",
"lenis": "^1.3.13",
"lucide-react": "^0.525.0",
"motion": "^12.23.12",
"next": "15.4.2",
Expand Down
4 changes: 4 additions & 0 deletions src/app/global.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
@import "tailwindcss";

@import "fumadocs-ui/css/shadcn.css";
@import "fumadocs-ui/css/preset.css";

@import "lenis/dist/lenis.css";

@import "tw-animate-css";

@custom-variant dark (&:is(.dark *));
Expand Down
3 changes: 2 additions & 1 deletion src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import LenisProvider from "@/components/providers/lenis-provider";
import SearchDialog from "@/components/search";
import { GoogleAnalytics } from "@next/third-parties/google";
import { RootProvider } from "fumadocs-ui/provider";
Expand Down Expand Up @@ -58,7 +59,7 @@ export default function RootLayout({ children }: { children: ReactNode }) {
SearchDialog,
}}
>
{children}
<LenisProvider>{children}</LenisProvider>
</RootProvider>
</body>
<GoogleAnalytics gaId={process.env.NEXT_PUBLIC_GOOGLE_ANALYTICS!} />
Expand Down
30 changes: 30 additions & 0 deletions src/components/providers/lenis-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client"; // Mark as a client component

import React, { useEffect } from "react";
import Lenis from "lenis";

const LenisProvider = ({ children }: { children: React.ReactNode }) => {
useEffect(() => {
const lenis = new Lenis({
duration: 1.2, // Customize duration
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)), // Custom easing
touchMultiplier: 2, // Multiplier for touch devices
wheelMultiplier: 1, // Multiplier for mouse wheel
});

function raf(time: number) {
lenis.raf(time);
requestAnimationFrame(raf);
}

requestAnimationFrame(raf);

return () => {
lenis.destroy(); // Clean up on unmount
};
}, []);

return <>{children}</>;
};

export default LenisProvider;