integration / lenissmooth scroll + scroll animation
Lenis + svg-scroll-draw, not a competition
Lenis is the smooth-scroll library everyone reaches for, and it comes up constantly as an “alternative” to scroll animation libraries. It is not one. Lenis eases the scroll itself; this library animates things against scroll position. They are complementary, they need nothing to join them, and that is why there is no /vs-lenis page here.
Short versionOn Lenis it just works, no adapter. Lenis 1.x scrolls the real page, so window.scrollY is always right.
- Lenis 1.3.26
- 5.3 KB
- svg-scroll-draw
- 11.9 KB
- Adapter for Lenis
- None
- Native CSS path
- Kept
wheel · touchwheel · touchlenis.raf (time)Eases the real scrollscroller tickEases a virtual valuewindow.scrollYmoved by Lenis’s scrollTo()window.scrollYnever updated — stalenoneNothing to addcreateLenisAdapter (scroller)patches scrollY, restores on destroyscrollDraw ()Reads the real valuescrollDraw ()Reads the patched valuethe path drawsIn step with the eased scrollthe path drawsIn step, once the adapter is inLenis 1.x: no adapter
Nothing special required. Every Lenis release so far is 1.x (2.0 exists only as development prereleases), and on every frame Lenis moves the real scroll position: its setScroll() calls scrollTo() with behavior: 'instant'. So window.scrollY follows the eased scroll, and every engine here reads it with no adapter and no configuration.
import Lenis from 'lenis';
import { scrollDraw } from 'svg-scroll-draw';
const lenis = new Lenis();
function raf(time) {
lenis.raf(time);
requestAnimationFrame(raf);
}
requestAnimationFrame(raf);
// No adapter: Lenis scrolls the real page, so window.scrollY is already right.
scrollDraw('#hero-svg', { easing: 'ease-out', speed: 1.2 });A custom wrapper
Give Lenis a wrapper element and it scrolls that element instead of the window. Point the animation at the same element with scrollContainer. A custom scroll container is one of the options the CSS path cannot express, so those animations run on the JavaScript engine.
import Lenis from 'lenis';
import { scrollDraw } from 'svg-scroll-draw';
const wrapper = document.querySelector('#scroller');
const lenis = new Lenis({ wrapper, content: wrapper.firstElementChild });
// …the same rAF loop as above
// Lenis scrolls #scroller, not the window: point the draw at it.
scrollDraw('#hero-svg', { scrollContainer: wrapper });What the adapter is for
svg-scroll-draw/lenis is for a scroller that keeps its position in a virtual value and never moves the page, so window.scrollY goes stale and animations look frozen. It takes anything with Lenis’s on('scroll') shape, patches window.scrollY and window.pageYOffset to report that value, and puts the browser’s own properties back on destroy. CSS still reads the real position, which does not move, so pass native: false.
import { createLenisAdapter } from 'svg-scroll-draw/lenis';
import { scrollDraw } from 'svg-scroll-draw';
// `scroller` keeps a virtual position and emits
// 'scroll' with { scroll, velocity, direction, progress }.
const adapter = createLenisAdapter(scroller);
// CSS reads the real scroll position, which never moves here.
scrollDraw('#hero-svg', { native: false });
// On teardown: puts the browser's own window.scrollY back.
// adapter.destroy();What the pair costs
Nothing in speed: because Lenis moves the real scroll position, a CSS view-timeline follows it, and where the browser supports animation-timeline the draw still runs as a native CSS scroll animation with no per-frame JavaScript. Elsewhere the JavaScript engine reads window.scrollY on each frame, as it would without Lenis. What you pay is bytes:
Lenis 1.3.26 is 5.3 KB gzipped, MIT, last published 2026-08-05. svg-scroll-draw 2.31.0 is 11.9 KB. Measured 2026-08-14 at gzip level 9.
Questions
Does svg-scroll-draw work with Lenis?
Yes, with no adapter. Every Lenis release so far is 1.x, and on every frame Lenis moves the real scroll position: its setScroll() calls scrollTo() on the window with behavior "instant". So window.scrollY follows the eased scroll and every engine here reads the right value. Run Lenis’s rAF loop and call scrollDraw as usual.
Is Lenis an alternative to svg-scroll-draw?
No — they do different jobs and are designed to be used together. Lenis eases the scroll itself; svg-scroll-draw animates elements against scroll position. Neither replaces the other, which is why there is no versus page for Lenis on this site.
Then what is svg-scroll-draw/lenis for?
A scroller that keeps its position in a virtual value and never moves the page, so window.scrollY goes stale. createLenisAdapter takes anything with Lenis’s on("scroll") / off("scroll") shape, patches window.scrollY and window.pageYOffset to report its value, and puts the browser’s own properties back on destroy. Lenis 1.x does not need it.
What about Lenis v2?
There is no Lenis v2 release yet: 2.0 exists only as development prereleases, and lenis on npm is 1.x. Advice that splits Lenis into a v1 that needs an adapter and a v2 that patches scrollY matches no release: the 1.x line already scrolls the real page.
Does smooth scrolling hurt scroll animation performance?
Not with Lenis. Because it moves the real scroll position, a CSS view-timeline follows it, so where the browser supports animation-timeline the draw still runs as a native CSS scroll animation with no per-frame JavaScript. The exception is a virtual scroller patched by the adapter: CSS reads the real position, which does not move, so pass native: false there and let the JS engine draw.