Independent scroll timelines
Sometimes 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.
The code
A shipping group's annual report. In the revenue chart the axes, each quarter's bar and the trend line draw inside their own slice of one scroll range, so the year builds up quarter by quarter as you read.
import { scrollDrawTimeline } from 'svg-scroll-draw/timeline';
scrollDrawTimeline('#revenue', {
trigger: { start: 'top 80%', end: 'bottom 60%' },
tracks: [
{ selector: '.axis', from: 0, to: 0.25, easing: 'ease-out' },
{ selector: '.q1', from: 0.12, to: 0.4, easing: 'ease-out' },
{ selector: '.q2', from: 0.26, to: 0.54, easing: 'ease-out' },
{ selector: '.q3', from: 0.4, to: 0.68, easing: 'ease-out' },
{ selector: '.q4', from: 0.54, to: 0.82, easing: 'ease-out' },
{ selector: '.trend', from: 0.74, to: 1, easing: 'ease-in-out' },
],
});
A shipping group’s annual report
Halyard Capital
Related examples
Make your own in the easing visualizer: set it up, watch it run, copy the code.
MIT licensed, zero runtime dependencies. Every API is a separate entry point, so you only ship what you import. Full API reference →