v2 · scrollVideo · currentTimeScroll-scrubbed video is the Apple product-page effect: the reader controls playback with the scroll wheel. Mechanically it is just video.currentTime driven by scroll progress, and the parts that are actually fiddly are preloading enough of the file to scrub without stalling and handling browsers that need Range requests. scrollVideo covers those.
Tie a <video> element's currentTime to scroll position — the Apple and Stripe product-page pattern. One function call. Supports from/to in seconds, preload strategy, onReady callback, and the full pause/resume/seek/replay instance API.
import { scrollVideo } from 'svg-scroll-draw/video';
// The full Apple / Stripe product scrub pattern.
// video.currentTime is tied directly to scroll position.
scrollVideo('#hero-video', {
// Animate across the full sticky section
trigger: { start: 'top top', end: 'bottom top' },
// Optionally scrub only a clip of the video
from: 0, // seconds
to: 12.5, // seconds (defaults to video.duration)
easing: 'linear', // linear feels most natural for scrub
once: false, // reverse on scroll-up
onReady: () => console.log('metadata loaded'),
onProgress: p => progressBar.style.width = p * 100 + '%',
onComplete: () => console.log('reached end'),
});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 →
Sticky pinned section on scroll
Pin an element while the page scrolls past it — the Apple and Stripe walkthrough pattern. Wrapper-based, no layout shift, full lifecycle callbacks.
Animate any CSS property on scroll
Drive opacity, transform, colour or any unit value from scroll position. Staggered per-element triggers build a natural reveal. Copy-paste code.