scrollDrawTimeline · independent tracksSometimes elements should not share a timeline at all: axes belong at the very start of the scroll range, bars across the middle, a trend line at the end. scrollDrawTimeline gives each track its own window expressed in percentages of the scroll range, which is closer to authoring keyframes than to wiring up triggers — and it is the closest thing here to GSAP’s timeline model.
Four quarterly bars and a trend line — each animated on its own independent scroll window using scrollDrawTimeline. Axes draw first (0→28%), then Q1–Q4 bars stagger across (10→88%), and the trend line traces last (75→100%) once all bars are fully visible.
import { scrollDrawTimeline } from 'svg-scroll-draw/timeline';
// Each track owns its own from/to slice of the scroll range.
// Unlike stagger (time offset), windows can overlap freely.
scrollDrawTimeline('#chart', {
trigger: { start: 'top 88%', end: 'top 25%' },
tracks: [
{ selector: '.axis', from: 0, to: 0.28, easing: 'ease-out' },
{ selector: '.bar-1', from: 0.1, to: 0.42, easing: 'ease-out' },
{ selector: '.bar-2', from: 0.26, to: 0.56, easing: 'ease-out' },
{ selector: '.bar-3', from: 0.42, to: 0.72, easing: 'ease-out' },
{ selector: '.bar-4', from: 0.58, to: 0.88, easing: 'ease-out' },
// Trend line draws only after all bars are visible
{ selector: '.trend', from: 0.75, to: 1.0, easing: 'spring' },
],
});npm i svg-scroll-draw
MIT licensed, zero runtime dependencies. Every API is a separate entry point, so you only ship what you import. Full API reference →
Animate one after another
Chain scroll animations so each starts only when the previous finishes. scrollDrawSequence handles the ordering — no manual delay maths.
Animate multiple SVGs together
Wire several separate SVG containers to one scroll timeline with scrollDrawGroup. They start together, no matter where they sit in the DOM.