Skip to content

Lenis and reduced motion: four gotchas

What I learned running Lenis smooth scroll with GSAP on a static Next.js site: reduced motion, nested scroll areas, anchors and loaders that lock scroll.

· Updated · 4 min read

The Banner Sizes tool card, a free tool whose inner scrolling list stopped working under Lenis

Lenis smooths the mouse wheel by scrolling the page itself, and that breaks four things unless you handle them: reduced motion, any scrollable area inside the page, in-page anchor links, and anything that must lock scroll, like a full-screen loader. Two of them shipped as bugs on this site, and I handled the other two up front.

This site runs Lenis on the GSAP ticker, with four fixes on top of the default setup.

The setup#

Lenis and ScrollTrigger need to step on the same frame, so Lenis runs from the GSAP ticker and tells ScrollTrigger about every scroll:

export function startSmoothScroll(): () => void {
  if (prefersReduced()) return () => {};
  lenis = new Lenis({ lerp: 0.1, wheelMultiplier: 1, anchors: true });
  lenis.on("scroll", ScrollTrigger.update);
  const tick = (time: number) => lenis?.raf(time * 1000);
  gsap.ticker.add(tick);
  gsap.ticker.lagSmoothing(0);
  return () => {
    gsap.ticker.remove(tick);
    gsap.ticker.lagSmoothing(500, 33);
    lenis?.destroy();
    lenis = null;
  };
}

lagSmoothing(0) turns off GSAP's lag smoothing while Lenis runs, and the cleanup restores it. Touch devices keep native scrolling, so Lenis only changes how a mouse wheel feels.

1. Reduced motion#

My rule is that Lenis is off under reduced motion. The first line of startSmoothScroll does that, and a small component restarts Lenis when the visitor flips the system setting while the page is open, not only at load:

useEffect(() => {
  const stop = reduced ? () => {} : startSmoothScroll();
  void document.fonts.ready.then(() => ScrollTrigger.refresh());
  return stop;
}, [reduced]);

The Lenis README for 1.3.26, the version I pin, says Lenis honors the setting by default: smoothing is disabled, programmatic scrolls jump to their targets, Lenis keeps running so WebGL and DOM synchronization stays intact, and the preference is picked up live without a reload. Turning that off with respectReducedMotion: false is the documented opt-out. I still switch Lenis off entirely under reduced motion, which is stricter, and the effect depends on reduced so the change applies live.

With Lenis off, links that scroll the page fall back to the native method, which also respects the preference:

el?.scrollIntoView({ behavior: prefersReduced() ? "auto" : "smooth" });

This is the same principle as in CSS spring and bounce with linear(): reduce the movement and keep the function. MDN notes that large movement can trigger discomfort for people with vestibular disorders.

2. Scrollable areas inside the page: data-lenis-prevent#

Lenis listens for the wheel on the whole document. A list with overflow: auto inside the page then stops responding, because Lenis cancels the native wheel scroll and moves the page instead, so the list never scrolls. This happened in my Banner Sizes tool, which had an inner scroll list. The wheel went to the page and the list could not be scrolled.

The README gives two fixes. The simple one is the allowNestedScroll: true option, which it warns can hurt performance because Lenis checks the DOM tree on every scroll event. The other is the data-lenis-prevent attribute on the element, which tells Lenis to leave it alone. There are also data-lenis-prevent-wheel and data-lenis-prevent-touch for one input type, and vertical and horizontal variants.

<div class="modal-body" data-lenis-prevent>
  <!-- Lenis ignores wheel and touch here, so the element scrolls natively -->
</div>

I use the attribute on the mobile menu sheet, on the true-size preview in Banner Sizes, which scrolls, and on scrollable panels in some other tools. For the Banner Sizes list itself I made a different choice: I removed the inner scroll area and laid the sizes out as tiles on the page, because a scroll area inside a scrolling page is awkward even when it works.

After that, a code block in one of the tools had the same problem: a scrollable block under the pointer did not take the wheel, and the page scrolled instead. Rather than add the attribute to every block by hand, I turned on allowNestedScroll: true in the Lenis constructor, which now covers every scrollable block on the site. The README warns that it checks the DOM tree on every scroll event. Lenis caches the check for each element for two seconds, and I have not measured any cost. An end-to-end test puts a scrollable block on a page, wheels over it and checks that the block scrolls and the page does not.

The README says Lenis prevents anchor links from working while it scrolls, unless you set anchors: true. I set it in the constructor above. If your in-page links do nothing, or only work when the page is still, check that option first.

4. Loaders and anything that locks scroll#

A full-screen loader has to lock scrolling, or the page scrolls behind it. I stop Lenis as well as locking the page. The README documents stop() and start() to pause and resume scrolling, and my loaders and the home intro call them. The site also keeps scrollbar-gutter: stable, so locking scroll does not shift the layout when the scrollbar disappears. The rest of that loader, from the static HTML to the exit, is in A WebGL loading screen before JavaScript.

Is Lenis worth it?#

It makes scroll-driven animation feel smooth with a mouse, and with GSAP's ScrollTrigger the two work well together. It also adds a layer that you now have to keep in line with native behaviour. Every fix above is a place where the native page did the right thing by default and Lenis made me do it again by hand. If your site has no scroll-linked animation, the plain browser scroll is the safer choice.

Gaps in my testing#

I have not tested these fixes with a screen reader or on real iOS Safari. Most of the behaviour is described from the README and my own pages, not from an accessibility audit.