v2 · scrollVideo · currentTime

Video scrubbing on scroll

Scroll-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.

The code

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.

Hero.tsx
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'),
});

Live — scroll it

scroll to scrub ↓

Install

terminal
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 →