🚀

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

Locomotive Smooth Scroll Setup

Documentation

Webflow

Code

Setup: External Scripts

HTML

Copy
<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/locomotive-scroll/bundled/locomotive-scroll.css">

<!-- JS -->
<script src="https://cdn.jsdelivr.net/npm/locomotive-scroll/bundled/locomotive-scroll.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
// Initialize Locomotive Scroll
const locomotiveScroll = new LocomotiveScroll();

Documentation

For all instance settings please read the Locomotive Scroll v5 Documentation.

Attributes

We highlighted some of the available attributes. Please read the documentation for all options.

  • data-scroll Enable viewport detection on an element.
  • data-scroll-speed Example: 0.1 or -0.05
  • data-scroll-offset Example: 25%, 50%
<h2 data-scroll data-scroll-speed="-0.5" data-scroll-offset="50%, 50%">What's up?</h2>
<p data-scroll data-scroll-speed="0.1">😬</p>
Copy

Options

Locomotive Scroll can use a lot of the options defined by Lenis, for a full list check out the documentation.

// Initialize Locomotive Scroll
const locomotiveScroll = new LocomotiveScroll({
  lenisOptions: {
    // Options (https://scroll.locomotive.ca/docs/documentation/options)
    lerp: 0.1,
    duration: 1.2,
    easing: (t) => Math.min(1, 1.001 - Math.pow(2, -10 * t)),
  }
});
Copy

Start Scroll

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

// Don't start Locomotive on load
const locomotiveScroll = new LocomotiveScroll({
  autoStart: false,
});

// Manually start it
function startScroll() {
  locomotiveScroll.start();
}
Copy

Stop/Pause Scroll

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

Destroy Scroll

Call locomotiveScroll.destroy(); to destroy the scroll.

Nested Scroll

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

Lenis Resources

To have a more basic setup with just Lenis check out our Lenis Smooth Scroll Resource.

Live preview

Osmo Robot AI

Copy context for AI

Beta

Webflow

HTML/CSS/JS

Save video

Copy share link

Resource details

  • Published

    June 23, 2025

  • Category

    Scroll Animations

  • Popularity

    3.3K visitors

  • Need help?

    Join Slack

Smooth
Scrolling
Locomotive
Progress
Parallax

Original source

OsmoOsmo

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