Scroll
JS behaviour
Horizontal scroll strip
Vertical scroll drives Meridian’s horizontal project gallery: the scroll wheel becomes translate on a sticky track, sweeping five project cards with hand-drawn SVG scenes past the frame — never a moment spent waiting on a wheel.
Real scenarios
The component as it is used in a product — not a specimen grid.
Keep scrolling down — the wheel never waits for a sideways drag. The five rollout projects of the quarter slide by on a sticky track, and the meter under the frame mirrors the same single progress variable.
Rollout strip — Q4
Meridian pipelines across five regions
Atlas pipeline
Aurora deploy
Harbor release
Cascade flags
Polar rollout
Strip progress: 0%
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| stage | length | '320vh' | The stage height; the scroll distance spent on the track’s full length. |
| --hst-p | 0 → 1 | 'stage progress' | The stage’s progress measured against its own position; one variable every motion derives from. |
| --hst-shift | px | 'track − viewport' | The net travel distance; re-measured on every resize so overflow stays at zero. |
| --hst-dir | ±1 | 'dir' | The travel sign; flips in RTL so the track always opens toward the story’s future. |
| progress | readout | '%' | The percentage readout under the frame; the same progress variable, no second math. |
Snippet
{{-- Horizontal scroll strip: vertical scroll drives the horizontal track --}}
<div class="hst" x-data="{
p: 0,
stop: () => {},
init() {
const root = this.$root, stage = root.querySelector('.hst-stage'),
viewport = root.querySelector('.hst-view'), track = root.querySelector('.hst-track');
let frame = 0, last = -1;
const measure = () => {
frame = 0;
const r = stage.getBoundingClientRect();
const span = Math.max(r.height - window.innerHeight, 1);
const p = Math.min(1, Math.max(0, -r.top / span));
const shift = Math.max(track.scrollWidth - viewport.clientWidth, 0);
root.style.setProperty('--hst-shift', shift + 'px');
const v = Math.round(p * 1000) / 1000;
if (v !== last) { last = v; this.p = v; root.style.setProperty('--hst-p', v); }
};
const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
addEventListener('scroll', schedule, { passive: true });
addEventListener('resize', schedule, { passive: true });
this.stop = () => {
cancelAnimationFrame(frame);
removeEventListener('scroll', schedule);
removeEventListener('resize', schedule);
};
measure();
},
destroy() { this.stop(); },
}">
<div class="hst-stage">
<div class="hst-view">
<div class="hst-track">
<article class="hst-card"><svg viewBox="0 0 320 200">…</svg>
<h3>Atlas pipeline</h3><small>Frankfurt · live</small></article>
<article class="hst-card"><svg viewBox="0 0 320 200">…</svg>
<h3>Aurora deploy</h3><small>Stockholm · canary</small></article>
<article class="hst-card"><svg viewBox="0 0 320 200">…</svg>
<h3>Harbor release</h3><small>Singapore · live</small></article>
</div>
</div>
</div>
<p class="hst-readout">Progress: <span x-text="Math.round(p * 100)">0</span>%</p>
</div>
<style>
.hst-stage { block-size: 320vh; }
.hst-view { position: sticky; inset-block-start: 10vh; block-size: 80vh;
overflow: clip; border-radius: 1.5rem; }
.hst-track { --hst-p: 0; --hst-shift: 0px; --hst-dir: -1;
display: flex; gap: 1.25rem; padding-inline: 1.5rem; inline-size: max-content;
translate: calc(var(--hst-p) * var(--hst-shift) * var(--hst-dir)) 0; }
[dir="rtl"] .hst-track { --hst-dir: 1; }
</style>
// app/Pages/Projects.jsx — Inertia (React) page; renders the React
// snippet below unchanged, with Inertia's Link wired into the provider.
import { Link } from '@inertiajs/react';
import { NabuXUIProvider } from '@nabuxai/ui-react';
import ProjectStrip from '@/components/ProjectStrip';
export default function Projects() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<ProjectStrip />
</main>
</NabuXUIProvider>
);
}
// ProjectStrip.jsx — vertical scroll drives a horizontal project track
import { useEffect, useRef, useState } from 'react';
import '@nabuxai/ui-core/css';
const PROJECTS = [
{ id: 'atlas', name: 'Atlas pipeline', region: 'Frankfurt', state: 'live' },
{ id: 'aurora', name: 'Aurora deploy', region: 'Stockholm', state: 'canary' },
{ id: 'harbor', name: 'Harbor release', region: 'Singapore', state: 'live' },
{ id: 'cascade', name: 'Cascade flags', region: 'Vancouver', state: 'scheduled' },
{ id: 'polar', name: 'Polar rollout', region: 'Oslo', state: 'live' },
];
export default function ProjectStrip() {
const rootRef = useRef(null);
const [pct, setPct] = useState(0);
// Progress measured against the stage's own rect; travel re-measured
// on resize so overflow never appears. Everything else is one CSS var.
useEffect(() => {
const root = rootRef.current;
const stage = root.querySelector('.hst-stage');
const viewport = root.querySelector('.hst-view');
const track = root.querySelector('.hst-track');
let frame = 0;
const measure = () => {
frame = 0;
const r = stage.getBoundingClientRect();
const span = Math.max(r.height - window.innerHeight, 1);
const p = Math.min(1, Math.max(0, -r.top / span));
root.style.setProperty('--hst-shift', Math.max(track.scrollWidth - viewport.clientWidth, 0) + 'px');
root.style.setProperty('--hst-p', p.toFixed(3));
setPct(Math.round(p * 100));
};
const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
window.addEventListener('scroll', schedule, { passive: true });
window.addEventListener('resize', schedule, { passive: true });
measure();
return () => {
cancelAnimationFrame(frame);
window.removeEventListener('scroll', schedule);
window.removeEventListener('resize', schedule);
};
}, []);
return (
<div className="hst" ref={rootRef}>
<style>{`
.hst-stage { block-size: 320vh; }
.hst-view { position: sticky; inset-block-start: 10vh; block-size: 80vh; overflow: clip;
border-radius: 1.5rem; }
.hst-track { --hst-p: 0; --hst-shift: 0px; --hst-dir: -1; display: flex; gap: 1.25rem;
padding-inline: 1.5rem; inline-size: max-content; align-items: center;
translate: calc(var(--hst-p) * var(--hst-shift) * var(--hst-dir)) 0; }
[dir='rtl'] .hst-track { --hst-dir: 1; }
.hst-card { inline-size: min(78vw, 26rem); border-radius: 1.25rem; background: #fff;
border: 1px solid #e4e4ef; overflow: clip; }
.hst-card svg { display: block; inline-size: 100%; }
.hst-card figcaption { padding: 1rem 1.25rem; }
.hst-readout { font: 600 .9rem system-ui; }
`}</style>
<div className="hst-stage">
<div className="hst-view">
<div className="hst-track">
{PROJECTS.map((project) => (
<figure className="hst-card" key={project.id}>
<svg viewBox="0 0 320 200" role="img" aria-label={project.name}>
<rect width="320" height="200" fill="#eef0fb" />
<circle cx="60" cy="120" r="16" fill="#5647e6" />
<circle cx="160" cy="70" r="16" fill="#2f9e6e" />
<circle cx="260" cy="130" r="16" fill="#c2530f" />
<path d="M74 113 L148 77 M174 77 L248 123" stroke="#5647e6" strokeWidth="4" fill="none" />
</svg>
<figcaption>
<h3 style={{ margin: 0 }}>{project.name}</h3>
<small>{project.region} · {project.state}</small>
</figcaption>
</figure>
))}
</div>
</div>
</div>
<p className="hst-readout">Progress: {pct}%</p>
</div>
);
}
<!-- ProjectStrip.vue — vertical scroll drives a horizontal project track -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
const projects = [
{ id: 'atlas', name: 'Atlas pipeline', region: 'Frankfurt', state: 'live' },
{ id: 'aurora', name: 'Aurora deploy', region: 'Stockholm', state: 'canary' },
{ id: 'harbor', name: 'Harbor release', region: 'Singapore', state: 'live' },
{ id: 'cascade', name: 'Cascade flags', region: 'Vancouver', state: 'scheduled' },
{ id: 'polar', name: 'Polar rollout', region: 'Oslo', state: 'live' },
];
const root = ref<HTMLElement | null>(null);
const pct = ref(0);
// Progress measured against the stage's own rect; travel re-measured on
// resize so overflow never appears. Everything else is one CSS var.
let frame = 0;
const measure = () => {
frame = 0;
const el = root.value;
if (!el) return;
const stage = el.querySelector('.hst-stage') as HTMLElement;
const viewport = el.querySelector('.hst-view') as HTMLElement;
const track = el.querySelector('.hst-track') as HTMLElement;
const r = stage.getBoundingClientRect();
const span = Math.max(r.height - window.innerHeight, 1);
const p = Math.min(1, Math.max(0, -r.top / span));
el.style.setProperty('--hst-shift', Math.max(track.scrollWidth - viewport.clientWidth, 0) + 'px');
el.style.setProperty('--hst-p', p.toFixed(3));
pct.value = Math.round(p * 100);
};
const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
onMounted(() => {
window.addEventListener('scroll', schedule, { passive: true });
window.addEventListener('resize', schedule, { passive: true });
measure();
});
onBeforeUnmount(() => {
cancelAnimationFrame(frame);
window.removeEventListener('scroll', schedule);
window.removeEventListener('resize', schedule);
});
</script>
<template>
<div ref="root" class="hst">
<div class="hst-stage">
<div class="hst-view">
<div class="hst-track">
<figure v-for="project in projects" :key="project.id" class="hst-card">
<svg viewBox="0 0 320 200" role="img" :aria-label="project.name">
<rect width="320" height="200" fill="#eef0fb" />
<circle cx="60" cy="120" r="16" fill="#5647e6" />
<circle cx="160" cy="70" r="16" fill="#2f9e6e" />
<circle cx="260" cy="130" r="16" fill="#c2530f" />
<path d="M74 113 L148 77 M174 77 L248 123" stroke="#5647e6" stroke-width="4" fill="none" />
</svg>
<figcaption>
<h3>{{ project.name }}</h3>
<small>{{ project.region }} · {{ project.state }}</small>
</figcaption>
</figure>
</div>
</div>
</div>
<p class="hst-readout">Progress: {{ pct }}%</p>
</div>
</template>
<style scoped>
.hst-stage { block-size: 320vh; }
.hst-view { position: sticky; inset-block-start: 10vh; block-size: 80vh; overflow: clip;
border-radius: 1.5rem; }
.hst-track { --hst-p: 0; --hst-shift: 0px; --hst-dir: -1; display: flex; gap: 1.25rem;
padding-inline: 1.5rem; inline-size: max-content; align-items: center;
translate: calc(var(--hst-p) * var(--hst-shift) * var(--hst-dir)) 0; }
:global([dir='rtl']) .hst-track { --hst-dir: 1; }
.hst-card { inline-size: min(78vw, 26rem); border-radius: 1.25rem; background: #fff;
border: 1px solid #e4e4ef; overflow: clip; margin: 0; }
.hst-card svg { display: block; inline-size: 100%; }
.hst-card figcaption { padding: 1rem 1.25rem; }
.hst-card h3 { margin: 0; }
.hst-readout { font: 600 .9rem system-ui; }
</style>
<!-- ProjectStrip.svelte — vertical scroll drives a horizontal project track -->
<script lang="ts">
import '@nabuxai/ui-core/css';
const projects = [
{ id: 'atlas', name: 'Atlas pipeline', region: 'Frankfurt', state: 'live' },
{ id: 'aurora', name: 'Aurora deploy', region: 'Stockholm', state: 'canary' },
{ id: 'harbor', name: 'Harbor release', region: 'Singapore', state: 'live' },
{ id: 'cascade', name: 'Cascade flags', region: 'Vancouver', state: 'scheduled' },
{ id: 'polar', name: 'Polar rollout', region: 'Oslo', state: 'live' },
];
let root: HTMLElement;
let pct = $state(0);
// Progress measured against the stage's own rect; travel re-measured on
// resize so overflow never appears. Everything else is one CSS var.
$effect(() => {
let frame = 0;
const measure = () => {
frame = 0;
const stage = root.querySelector('.hst-stage') as HTMLElement;
const viewport = root.querySelector('.hst-view') as HTMLElement;
const track = root.querySelector('.hst-track') as HTMLElement;
const r = stage.getBoundingClientRect();
const span = Math.max(r.height - window.innerHeight, 1);
const p = Math.min(1, Math.max(0, -r.top / span));
root.style.setProperty('--hst-shift', Math.max(track.scrollWidth - viewport.clientWidth, 0) + 'px');
root.style.setProperty('--hst-p', p.toFixed(3));
pct = Math.round(p * 100);
};
const schedule = () => { if (!frame) frame = requestAnimationFrame(measure); };
window.addEventListener('scroll', schedule, { passive: true });
window.addEventListener('resize', schedule, { passive: true });
measure();
return () => {
cancelAnimationFrame(frame);
window.removeEventListener('scroll', schedule);
window.removeEventListener('resize', schedule);
};
});
</script>
<div bind:this={root} class="hst">
<div class="hst-stage">
<div class="hst-view">
<div class="hst-track">
{#each projects as project (project.id)}
<figure class="hst-card">
<svg viewBox="0 0 320 200" role="img" aria-label={project.name}>
<rect width="320" height="200" fill="#eef0fb" />
<circle cx="60" cy="120" r="16" fill="#5647e6" />
<circle cx="160" cy="70" r="16" fill="#2f9e6e" />
<circle cx="260" cy="130" r="16" fill="#c2530f" />
<path d="M74 113 L148 77 M174 77 L248 123" stroke="#5647e6" stroke-width="4" fill="none" />
</svg>
<figcaption>
<h3>{project.name}</h3>
<small>{project.region} · {project.state}</small>
</figcaption>
</figure>
{/each}
</div>
</div>
</div>
<p class="hst-readout">Progress: {pct}%</p>
</div>
<style>
.hst-stage { block-size: 320vh; }
.hst-view { position: sticky; inset-block-start: 10vh; block-size: 80vh; overflow: clip;
border-radius: 1.5rem; }
.hst-track { --hst-p: 0; --hst-shift: 0px; --hst-dir: -1; display: flex; gap: 1.25rem;
padding-inline: 1.5rem; inline-size: max-content; align-items: center;
translate: calc(var(--hst-p) * var(--hst-shift) * var(--hst-dir)) 0; }
[dir='rtl'] .hst-track { --hst-dir: 1; }
.hst-card { inline-size: min(78vw, 26rem); border-radius: 1.25rem; background: #fff;
border: 1px solid #e4e4ef; overflow: clip; margin: 0; }
.hst-card svg { display: block; inline-size: 100%; }
.hst-card figcaption { padding: 1rem 1.25rem; }
.hst-card h3 { margin: 0; }
.hst-readout { font: 600 .9rem system-ui; }
</style>