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
<!-- 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
HTML structure is not required for this resource.
Step 2: Add CSS
CSS
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
// 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
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
Last updated
January 23, 2025
Type
Osmo Basics
Category
Utilities & Scripts
Need help?
Join Slack