Searching Open Sourcery

Type to search Open Sourcery.

Motion & Scroll

Scroll Progress

Scroll progress with configurable playhead anchors, smoothing, and CSS variable output.

v1.1.0@magic-spells/scroll-progress

$ npm i @magic-spells/scroll-progress

GitHubnpm

Usage

<scroll-progress
  playhead-element-start="top"
  playhead-viewport-start="bottom"
  playhead-element-end="bottom"
  playhead-viewport-end="top">
  <!-- child elements animated with --scroll-progress -->
  <div 
    class="animated-layer" 
    style="transform: translateX(calc(var(--scroll-progress) * 100%));">
    Scroll me!
  </div>
</scroll-progress>

About

A high-performance, customizable Web Component that tracks scroll progress relative to configurable playhead anchors on the element and viewport. It exposes smooth, GPU-accelerated CSS variables (--scroll-progress and --scroll-progress-velocity) for scroll-based animations without relying on scroll event listeners.

Features

  • 🎯 Configurable playhead anchors for both element and viewport start/end positions — keywords or percentages
  • 🪶 Optional progress smoothing with a frame-rate independent time constant
  • ⚡ Optimized animations driven by requestAnimationFrame (no scroll events)
  • 🖥️ GPU accelerated using will-change: transform and backface-visibility: hidden
  • 🕵️‍♂️ Visibility-aware updates using Intersection Observer to minimize CPU usage
  • 📏 Responsive to viewport resizes with throttled resize handling

About, features, usage and options are taken from the package README.