Solid.js scroll animation

Solid’s fine-grained reactivity means an animation library must not force re-renders to move a value, and this one does not — the draw runs outside the reactive graph entirely, driven by scroll position. The example animates a signal feeding two memos into an effect, which is a fitting subject: the diagram explains the model the code is written in.

12Solid · useScrollDraw

The code

A payments API's public status page. Each service's 24-hour latency line draws as its row scrolls in — the webhook incident spike included — written here as you would in Solid with useScrollDraw.

Hero.tsx17 lines
import { useScrollDraw } from 'svg-scroll-draw/solid';
import { For } from 'solid-js';

function Sparkline(props) {
  const ref = useScrollDraw({
    trigger: { start: 'top 92%', end: 'top 55%' },
    easing:  'ease-out',
    once:    true,
  });
  return (
    <div ref={ref} class="spark">
      <svg viewBox="0 0 480 60"><path d={props.d} /></svg>
    </div>
  );
}

<For each={services}>{(s) => <Sparkline d={s.latency} />}</For>
Paygrid status, a payments api’s live status page: the first screen of its demo site

A payments API’s live status page

Paygrid status

Live site

Related examples

MIT licensed, zero runtime dependencies. Every API is a separate entry point, so you only ship what you import. Full API reference →