Mastering Smooth UI Animations with GSAP and Lenis

AUTHOR:SURAJ K.S DATE:05.24.2026 READ TIME:8 MIN TOPIC:GSAP & LENIS

Modern web design has evolved past flat interfaces. Today, high-end digital products command attention through motion. However, animation without optimization is a recipe for high latency, layout shifting, and a frustrating user experience. Jittery scrolling breaks immersion, ruining the premium feel you worked hard to build.

To achieve fluid, buttery-smooth scrolling synchronized with cinematic visual reveals, two tools stand out as the modern standard: GSAP ScrollTrigger and Lenis Smooth Scroll. When combined correctly, they allow web developers to build immersive, performant, and physics-driven storytelling experiences. In this masterclass, we will explore how to integrate, synchronize, and optimize this stack for production-grade websites.

Fluidity isn’t just about framerates; it is about input synchronization. When a user's trackpad scroll matches the rendering timeline precisely, the interface transforms from a webpage into an extension of their hand.

STAGE 1: Why Smooth Scrolling Needs Lenis

Standard browser scrolling is discrete and rigid. Browsers jump scroll coordinates page by page, resulting in abrupt movement. While browsers have attempted smooth scrolling features, they lack consistency across devices (trackpads, mouse wheels, and touch screens) and operating systems.

Lenis is a lightweight, open-source smooth-scrolling library designed by Studio Freight. Unlike older scroll-jacking libraries, Lenis is non-invasive. It works on the main thread, preserves browser defaults, handles keyboard navigation gracefully, and respects CSS pointer events. Most importantly, it calculates physics-based scroll coordinates that we can leverage for visual tweens.

When you trigger scroll animations, GSAP's ScrollTrigger calculates element boundaries relative to the viewport. Under normal conditions, GSAP polls the browser’s scroll position. However, when Lenis recalculates the scroll animation loop inside a custom requestAnimationFrame loop, the visual elements and the browser's native scroll properties can fall out of sync, leading to stuttering, tearing, or lagging effects.

STAGE 2: Linking the Timelines (ScrollTrigger & Lenis Sync)

To solve this, we must configure a bridge that updates GSAP’s ScrollTrigger markers exactly when Lenis calculates a new scroll offset. This is done by adding Lenis's request animation frame updates to the GSAP ticker.

Let's look at the initialization script. We load Lenis, GSAP, and ScrollTrigger, then instantiate Lenis and link it to GSAP's render loop.

// 1. Initialize Lenis Smooth Scroll
const lenis = new Lenis({
    duration: 1.2,
    easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
    orientation: 'vertical',
    gestureOrientation: 'vertical',
    smoothWheel: true,
    wheelMultiplier: 1
});

// 2. Connect ScrollTrigger to Lenis Scroll Events
lenis.on('scroll', ScrollTrigger.update);

// 3. Use GSAP's Ticker to drive Lenis Updates
gsap.ticker.add((time) => {
    lenis.raf(time * 1000); // convert time to milliseconds
});

// 4. Disable Lag Smoothing for immediate response
gsap.ticker.lagSmoothing(0);

Let's analyze what this setup does. First, the Lenis instance uses an exponential decay easing curve to make mouse wheel movement slide slowly to a stop. Next, lenis.on('scroll', ScrollTrigger.update) updates ScrollTrigger's geometric calculations immediately upon scroll. Finally, by wiring lenis.raf() to GSAP's ticker, we guarantee that scroll recalculations and tween rendering happen in the exact same paint frame.

STAGE 3: Advanced Scroll-Triggered Patterns

With synchronization handled, we can build high-end UI patterns. Below are two patterns frequently used in premium websites:

1. Element Reveal (Staggered Fade-Up)

Instead of elements popping in awkwardly, stagger their appearance as they scroll into view. Using gsap.fromTo with a scroll trigger triggers the animation cleanly when the element is 15% from the bottom of the viewport.

gsap.fromTo(".reveal-item", 
    { opacity: 0, y: 50 },
    { 
        opacity: 1, 
        y: 0, 
        stagger: 0.15,
        duration: 1,
        ease: "power3.out",
        scrollTrigger: {
            trigger: ".reveal-container",
            start: "top 85%"
        }
    }
);

2. Horizontal Scroll Scrubbing

Scrubbing links the animation playhead directly to scroll progression. We can lock the screen in place (pinning) and slide a container horizontally as the user scroll downwards.

gsap.to(".horizontal-track", {
    x: () => -(document.querySelector('.horizontal-track').scrollWidth - window.innerWidth),
    ease: "none",
    scrollTrigger: {
        trigger: ".horizontal-wrapper",
        start: "top top",
        end: () => "+=" + document.querySelector('.horizontal-track').scrollWidth,
        scrub: true,
        pin: true,
        invalidateOnRefresh: true
    }
});

STAGE 4: Performance Boss Fight

Animations should enhance, not degrade, usability. Keep these practices in mind to optimize execution speeds:

  • CSS will-change: Use will-change: transform, opacity on animated cards. This forces the browser to delegate rendering tasks directly to the GPU, minimizing layout calculations on the main CPU thread.
  • Invalidate on Refresh: Set invalidateOnRefresh: true inside triggers that use window heights. This forces GSAP to recalculate positions when layouts shift or screen sizes scale (especially on mobile orientation changes).
  • Destroy and Kill: Memory leaks quickly degrade browser performance. Always call scrollTrigger.kill() and lenis.destroy() when unmounting web pages in modern frameworks.

Integrating GSAP and Lenis allows you to control motion, timeline, and input speed. By building layouts that adapt to user interaction, you elevate your web products from static pages to interactive, dynamic digital art.

Try implementing this configuration on your next landing page project. Feel free to reach out with details about your animation performance or layout ideas!

GSAP EASE PLAYGROUND

Y (Value) X (Time) target
GSAP TIMELINE

Enquiry Form

Contact me for web development services.

Success!
Sent! Expect a response from Suraj shortly.