🚀

Update available

We just released a new resource or update, refresh the Vault to access the latest version.

Cancel

Refresh now

Harri

Profile Picture

Harri

Lemke

Lenis Smooth Scroll Setup

Documentation

Webflow

Code

Setup: External Scripts

HTML

Copy
<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/lenis@1.2.3/dist/lenis.css">

<!-- JS -->
<script src="https://cdn.jsdelivr.net/npm/lenis@1.2.3/dist/lenis.min.js"></script> 

Step 1: Add HTML

HTML structure is not required for this resource.

Step 2: Add Javascript

Step 3: Add Javascript

Javascript

Copy
// Lenis
const lenis = new Lenis({
  autoRaf: true,
});

Implementation

Documentation

For all instance settings please read the Lenis Documentation on Github

Nested Scroll

For modals or other elements that have overflow: scroll; add the data-attribute [data-lenis-prevent]

Stop/Pause Scroll

Call lenis.stop(); to disable the scroll for the user, for example when opening a modal.

Start Scroll

Call lenis.start(); to enable scroll again.

Scroll-To Anchor Target

For more information how to implement lenis.scrollTo(): Lenis Scroll-To Anchor Target

Using with GSAP Scrolltrigger

// Lenis (with GSAP Scroltrigger)
const lenis = new Lenis();
lenis.on('scroll', ScrollTrigger.update);
gsap.ticker.add((time) => {lenis.raf(time * 1000);});
gsap.ticker.lagSmoothing(0);
Copy

Live preview

Osmo Robot AI

Copy context for AI

Beta

Webflow

HTML/CSS/JS

Copy share link

Resource details

  • Published

    December 30, 2024

  • Category

    Utilities & Scripts

  • Popularity

    5.6K visitors

  • Need help?

    Join Slack

Lenis
Script
Setup
Smooth
Scrolling

Original source

LenisLenis

Creator Credits

We always strive to credit creators as accurately as possible. While similar concepts might appear online, we aim to provide proper and respectful attribution.

s