Quick search and commands navigation
A mechanical ruler scroll indicator with sub-pixel vernier kinematics, zero-layout-shift RAF scroll spy, and synthetic micro-haptic audio feedback. Hover the rail or scroll the viewport to inspect.
The vertical track recreates an industrial mechanical vernier height gauge. It renders 60 discrete laser-calibrated tick subdivisions along the right edge with a 5-tick major cadence.
As scroll position advances, ticks ahead of the cursor remain dim while traversed ticks illuminate with higher opacity, providing instantaneous visual proprioception of document depth.
Rather than binding raw scroll offsets directly to the DOM, the indicator channels movement through a damped harmonic oscillator (stiffness: 280, damping: 30, mass: 0.4).
This decouples the visual pointer from erratic mousewheel spikes or abrupt trackpad inertia, creating a tactile, fluid gliding sensation reminiscent of heavy precision optics.
Tactile feedback is reinforced using discrete Web Audio API synthesis. When scrubbing the ruler or hovering section anchors, short 800Hz–1200Hz sine bursts trigger with micro-decay envelopes.
No external audio files or MP3 network payloads are downloaded—everything is synthesized dynamically on an in-memory AudioContext with zero latency.
The scroll spy uses a passive RequestAnimationFrame loop that throttles geometry queries to the monitor native refresh rate.
Section offsets are measured with client bounding boxes and compared against a 20% viewport threshold, guaranteeing zero cumulative layout shifts (CLS) and smooth 60/120fps rendering.
{ passive: true } and cancelAnimationFrame cleanup to eliminate thread blocking.Pass any standard React RefObject to scrollRef to bind the indicator to a nested overflow pane, modal, or drawer. If omitted, the indicator automatically falls back to listening to the global window scroll event.
Supports custom click callbacks, controlled activeIndex, and arbitrary tick counts.
// Drop-in React usage:
<ScrollIndicator
sections={sections}
scrollRef={containerRef}
totalTicks={60}
scrollOffset={64}
className="h-full"
/>