Rail Scroll Scrubber
NewmotionKinetic scrollbar and precision section scrubber featuring a 5-stage continuous rail path, split-character peeling, and zoom overview lens.
$ pnpm dlx shadcn@latest add @byphongphan/rail-scroll-scrubber@byphongphan in components.jsonLive Interactive Stage
The Rail Scroll Scrubber is an ultra-precision kinetic scroll indicator and section scrubber inspired by cutting-edge creative engine viewports. As the page scrolls, individual characters of section titles fly along a continuous 5-stage rail track: peeling off a bottom waiting stack, navigating smooth quarter-circle arcs, riding flush against vertical ruler ticks, and arriving into an expanded top active header.
Engineering Highlights
- 5-Stage Continuous Rail Solver: An analytical track geometry solver evaluates exact character positions, scale, 2D rotation, and color tint across 5 physical stages at 120fps.
- Split-Character Peeling: Each letter in every section title travels independently with train-car offsets, so words like
OWNERSHIPalign vertically (-90°) against ruler ticks or turn corners letter-by-letter. - Dual-State Overview Zoom Lens: Renders an expanded focal view by default, but smoothly interpolates into a complete
0–100%viewport overview with translucent lens highlighting when hovered or scrubbed. - Sub-Pixel Ruler Navigation: 0–100 calibrated ticks with glowing laser progress bar and padded monospace percentage readout (e.g.
047%,068%). - Interactive Drag & Snap: Click and drag anywhere along the ruler rail to jump to sections or smoothly glide across the page.
Installation
Install dependencies:
$ pnpm add motion@byphongphan in components.jsonCopy and paste the component into your project:
Update import paths to match your project structure.
Usage
1. Basic Window Scroll Integration
Mount the scrubber to replace or augment the native scrollbar on the main window:
2. Custom Scroll Container & Sections
Connect to a dedicated scrollable container using Framer Motion's useScroll:
Props
| Prop | Type | Default | Description |
|---|---|---|---|
sections | RailSection[] | DEFAULT_RAIL_SECTIONS | Array of section descriptors with title, coordinates, and flight ranges. |
scrollProgressMV | MotionValue<number> | window scroll | Optional custom scroll progress MotionValue (0..1). |
onScrubToProgress | (progress: number) => void | window.scrollTo | Callback when dragging the ruler to scrub to a percentage. |
springConfig | SpringConfig | { stiffness: 140, damping: 26, mass: 0.45 } | Spring physics parameters for scroll smoothing. |
zoomScale | number | 3.6 | Magnification factor for zoomed ruler ticks. |
curveIntensity | number | 1.0 | Radius multiplier for top and bottom transition curves. |
accentColor | string | "var(--primary)" | Color of the progress laser line and glow effects. |
className | string | undefined | Additional CSS class names. |