Smooth Scrolling : Navigating the Challenges
Here I've shared the most easy & straight forward method to achieve Smooth Scrolling in React / Next Js applications (with source code)

Artist, Designer & Developer
Search for a command to run...
Here I've shared the most easy & straight forward method to achieve Smooth Scrolling in React / Next Js applications (with source code)

Artist, Designer & Developer
No comments yet. Be the first to comment.
Here, I'll share & seek Programming & Creative Development Knowledge
We will be creating a NextJs component that receives a string as a prop & animates it, Code below 👇 Note: Use Variable fonts to get seamless animation. Mona Sans is used for this example As a bonus, We will be using Framer motion & Tailwind CSS to t...
We will be creating a NextJs component that receives a string as a prop & animates it, Code below 👇 Note: Use Variable fonts to get seamless animation. Mona Sans is used for this example As a bonus, We will be using Framer motion & Tailwind CSS to t...

What is Design System? What are the contents? Examples of a good Design System? and more...

Here are some fundamentals design principles you must know

Here you will find a few definitions of Design by various authors & popular designers

Smooth scrolling, the eye-pleasing navigation feature, transforms user experience. However, its implementation is no cakewalk. Let's demystify the complexities and provide a clear guide for achieving seamless scrolling on your website.
Beyond visual appeal, smooth scrolling enhances user engagement. Its absence of abrupt transitions creates a more enjoyable experience, impacting user satisfaction positively.
Cross-browser compatibility, performance issues, glitches, and synchronized animations pose challenges in crafting the perfect smooth scroll experience, especially while using Next Js
if you're a Next Js person, use this in your layout.jsx file with necessary adjustments like adding "use client" etc.
else if you are a React person use it in your App.js
import Lenis from "@studio-freight/lenis";
function App(){
useEffect(() => {
// Create a Lenis instance, a library for smooth scrolling effects.
const lenis = new Lenis({
duration: 1.5,
// Fine-tune the smoothness of the animation, values closer to 0 will be dead smooth.
lerp: 0.05,
// Define the easing function for a natural acceleration and deceleration.
easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
// Choose the scrolling direction (vertical or horizontal).
direction: "vertical",
// Set the allowed gesture direction for scrolling (vertical, horizontal, or both).
gestureDirection: "vertical",
// Enable smooth scrolling.
smooth: true,
// Disable smooth scrolling on touch devices.
smoothTouch: false,
// Adjust the sensitivity of touch-based scrolling.
touchMultiplier: 2,
});
// Create a requestAnimationFrame loop to continuously update the Lenis instance.
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
// Start the requestAnimationFrame loop.
requestAnimationFrame(raf);
}, []);
return(
<div>
<h1>Finally! Smooth scroll</h1>
<p>Thanks to <strong>@studio-freight</strong> for this amazing plugin</p>
</div>
);
}
Thanks for visiting this blog, Feel free to reach me for creating Modern Interactive Web development projects, Visit my portfolio - Hariprasad and my Design agency