Copied SVG to clipboard
Something went wrong
Copied code to clipboard
Something went wrong

Default

User image

Default

Name

  • Osmo Discount
    -25%
Osmo Basics/

Lenis Smooth Scroll Setup

Lenis Smooth Scroll Setup

Documentation

Webflow

Code

Setup: External Scripts

External Scripts in Webflow

Make sure to always put the External Scripts before the Javascript step of the resource.

In this video you learn where to put these in your Webflow project? Or how to include a paid GSAP Club plugin in your project?

HTML

Copy
<!-- CSS -->
<link rel="stylesheet" href="https://unpkg.com/lenis@1.1.20/dist/lenis.css">

<!-- JS -->
<script src="https://unpkg.com/lenis@1.1.20/dist/lenis.min.js"></script> 

Step 1: Copy structure to Webflow

Copy structure to Webflow

In the video below we described how you can copy + paste the structure of this resource to your Webflow project.

Copy to Webflow

Webflow structure is not required for this resource.

Step 1: Add HTML

HTML

Copy

HTML structure is not required for this resource.

Step 2: Add CSS

CSS

Copy

Step 2: Add custom Javascript

Custom Javascript in Webflow

In this video, Ilja gives you some guidance about using JavaScript in Webflow:

Step 2: Add Javascript

Step 3: Add Javascript

Javascript

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

Step 3: Add custom CSS

Step 2: Add custom CSS

Custom CSS in Webflow

Curious about where to put custom CSS in Webflow? Ilja explains it in the below video:

CSS

Copy

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);

Resource Details

Lenis
Script
Setup
Smooth
Scrolling

Original source

Lenis

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.