Parallax depth
One Meridian rollout day in three speeds: slow ghost numerals in the back, the Dublin-to-São-Paulo narrative mid-frame, and foreground chips racing past — depth built from a single progress variable and a handful of calcs.
Real scenarios
The component as it is used in a product — not a specimen grid.
Scroll slowly: the numerals crawl, the story holds, the chips fly. Three speeds over one scroll pass — a day of Meridian releases told in depth, from the first commit in Dublin to the full rollout in São Paulo.
09:15 · Dublin One commit starts the story 2 reviewed files · 1 green build
11:40 · Singapore Canary on 5% of traffic Error rate flat · 9 regions watching
16:20 · São Paulo Full rollout, nobody on call 24 regions · 12-minute rollback in reach
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| stage | length | '340vh' | The stage height; the sticky scene stays on screen through all of it. |
| bg · fg speed | vh | '8 · 30' | Back and front travel derived from that one progress value; the middle layer (the story) stays put and only crossfades. |
| beats | count | '3' | Three narrative beats; each fully lit within ±12% of its centre and gone by ±30%. |
| --pdz-on | 0 → 1 | 'per beat' | Each beat’s brightness, written in the same scroll pass; paired with a slight rise as it appears. |
| layers | pointer-events | 'none' | Decorative layers swallow no clicks; only the story layer is interactive. |
Snippet
{{-- Multi-layer parallax: three speeds, one progress variable --}}
<div class="pdz" x-data="{
stop: () => {},
init() {
const root = this.$root, stage = root.querySelector('.pdz-stage'),
beats = [...this.$root.querySelectorAll('.pdz-beat')];
let frame = 0, last = -1;
const centers = beats.map((_, i) => (i + .5) / beats.length);
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));
beats.forEach((beat, i) => {
const on = Math.min(1, Math.max(0, (.3 - Math.abs(p - centers[i])) / .18));
beat.style.setProperty('--pdz-on', on.toFixed(3));
});
const v = Math.round(p * 1000) / 1000;
if (v !== last) { last = v; root.style.setProperty('--pdz-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="pdz-stage">
<div class="pdz-view">
<div class="pdz-bg"><span>01</span><span>02</span><span>03</span></div>
<div class="pdz-mid">
<p class="pdz-beat"><small>09:15 · Dublin</small><b>One commit starts the story</b></p>
<p class="pdz-beat"><small>11:40 · Singapore</small><b>Canary on 5% of traffic</b></p>
<p class="pdz-beat"><small>16:20 · São Paulo</small><b>Full rollout, nobody on call</b></p>
</div>
<div class="pdz-fg">
<span class="pdz-chip">+23% deploy frequency</span>
<span class="pdz-chip">99.98% uptime</span>
</div>
</div>
</div>
</div>
<style>
.pdz-stage { block-size: 340vh; }
.pdz-view { position: sticky; inset-block-start: 0; block-size: 100svh; overflow: clip;
display: grid; place-items: center; }
.pdz-bg, .pdz-fg { position: absolute; inset: 0; pointer-events: none; }
.pdz-bg { --pdz-p: 0; font-weight: 800; font-size: 34vmin; color: #1d1b2e0d;
display: flex; justify-content: space-around; align-items: center;
translate: 0 calc(var(--pdz-p) * -8vh); }
.pdz-fg { --pdz-p: 0; translate: 0 calc(var(--pdz-p) * -30vh); }
.pdz-beat { --pdz-on: 0; grid-area: 1 / 1; text-align: center;
opacity: var(--pdz-on); translate: 0 calc((1 - var(--pdz-on)) * 1.5rem); }
.pdz-chip { position: absolute; padding: .5rem 1rem; border-radius: 999px;
background: #fff; font-weight: 600; font-size: .85rem; }
</style>
// app/Pages/RolloutDay.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 RolloutDay from '@/components/RolloutDay';
export default function Page() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<RolloutDay />
</main>
</NabuXUIProvider>
);
}
// RolloutDay.jsx — multi-layer parallax: three speeds, one progress variable
import { useEffect, useRef } from 'react';
import '@nabuxai/ui-core/css';
const BEATS = [
{ at: '09:15', city: 'Dublin', line: 'One commit starts the story' },
{ at: '11:40', city: 'Singapore', line: 'Canary on 5% of traffic' },
{ at: '16:20', city: 'São Paulo', line: 'Full rollout, nobody on call' },
];
export default function RolloutDay() {
const rootRef = useRef(null);
// One scroll pass: stage progress against its own rect drives the
// two drifting layers; each beat's brightness is written per element.
useEffect(() => {
const root = rootRef.current;
const stage = root.querySelector('.pdz-stage');
const beats = [...root.querySelectorAll('.pdz-beat')];
const centers = beats.map((_, i) => (i + 0.5) / beats.length);
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('--pdz-p', p.toFixed(3));
beats.forEach((beat, i) => {
const on = Math.min(1, Math.max(0, (0.3 - Math.abs(p - centers[i])) / 0.18));
beat.style.setProperty('--pdz-on', on.toFixed(3));
});
};
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="pdz" ref={rootRef}>
<style>{`
.pdz-stage { block-size: 340vh; }
.pdz-view { position: sticky; inset-block-start: 0; block-size: 100svh; overflow: clip;
display: grid; place-items: center; background: #f4f4fa; }
.pdz-bg, .pdz-fg { position: absolute; inset: 0; pointer-events: none; }
.pdz-bg { --pdz-p: 0; font-weight: 800; font-size: 34vmin; color: rgba(29, 27, 46, .05);
display: flex; justify-content: space-around; align-items: center;
translate: 0 calc(var(--pdz-p) * -8vh); }
.pdz-mid { display: grid; }
.pdz-beat { --pdz-on: 0; grid-area: 1 / 1; margin: 0; text-align: center;
opacity: var(--pdz-on); translate: 0 calc((1 - var(--pdz-on)) * 1.5rem); }
.pdz-beat small { display: block; font-size: .85rem; letter-spacing: .08em; color: #5c5a75; }
.pdz-beat b { font-size: clamp(1.5rem, 4.5vw, 2.6rem); }
.pdz-fg { --pdz-p: 0; translate: 0 calc(var(--pdz-p) * -30vh); }
.pdz-chip { position: absolute; padding: .5rem 1rem; border-radius: 999px; background: #fff;
font: 600 .85rem system-ui; box-shadow: 0 8px 22px rgba(24, 20, 52, .12); }
.pdz-chip:nth-child(1) { inset-inline-start: 12%; inset-block-start: 24%; }
.pdz-chip:nth-child(2) { inset-inline-end: 10%; inset-block-end: 28%; }
`}</style>
<div className="pdz-stage">
<div className="pdz-view">
<div className="pdz-bg" aria-hidden="true">
<span>01</span><span>02</span><span>03</span>
</div>
<div className="pdz-mid">
{BEATS.map((beat) => (
<p className="pdz-beat" key={beat.city}>
<small>{beat.at} · {beat.city}</small>
<b>{beat.line}</b>
</p>
))}
</div>
<div className="pdz-fg" aria-hidden="true">
<span className="pdz-chip">+23% deploy frequency</span>
<span className="pdz-chip">99.98% uptime</span>
</div>
</div>
</div>
</div>
);
}
<!-- RolloutDay.vue — multi-layer parallax: three speeds, one progress variable -->
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
const beats = [
{ at: '09:15', city: 'Dublin', line: 'One commit starts the story' },
{ at: '11:40', city: 'Singapore', line: 'Canary on 5% of traffic' },
{ at: '16:20', city: 'São Paulo', line: 'Full rollout, nobody on call' },
];
const root = ref<HTMLElement | null>(null);
// One scroll pass: stage progress against its own rect drives the two
// drifting layers; each beat's brightness is written per element.
let frame = 0;
const measure = () => {
frame = 0;
const el = root.value;
if (!el) return;
const stage = el.querySelector('.pdz-stage') as HTMLElement;
const nodes = [...el.querySelectorAll('.pdz-beat')] as HTMLElement[];
const centers = nodes.map((_, i) => (i + 0.5) / nodes.length);
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('--pdz-p', p.toFixed(3));
nodes.forEach((beat, i) => {
const on = Math.min(1, Math.max(0, (0.3 - Math.abs(p - centers[i])) / 0.18));
beat.style.setProperty('--pdz-on', on.toFixed(3));
});
};
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="pdz">
<div class="pdz-stage">
<div class="pdz-view">
<div class="pdz-bg" aria-hidden="true"><span>01</span><span>02</span><span>03</span></div>
<div class="pdz-mid">
<p v-for="beat in beats" :key="beat.city" class="pdz-beat">
<small>{{ beat.at }} · {{ beat.city }}</small>
<b>{{ beat.line }}</b>
</p>
</div>
<div class="pdz-fg" aria-hidden="true">
<span class="pdz-chip">+23% deploy frequency</span>
<span class="pdz-chip">99.98% uptime</span>
</div>
</div>
</div>
</div>
</template>
<style scoped>
.pdz-stage { block-size: 340vh; }
.pdz-view { position: sticky; inset-block-start: 0; block-size: 100svh; overflow: clip;
display: grid; place-items: center; background: #f4f4fa; }
.pdz-bg, .pdz-fg { position: absolute; inset: 0; pointer-events: none; }
.pdz-bg { --pdz-p: 0; font-weight: 800; font-size: 34vmin; color: rgba(29, 27, 46, .05);
display: flex; justify-content: space-around; align-items: center;
translate: 0 calc(var(--pdz-p) * -8vh); }
.pdz-mid { display: grid; }
.pdz-beat { --pdz-on: 0; grid-area: 1 / 1; margin: 0; text-align: center;
opacity: var(--pdz-on); translate: 0 calc((1 - var(--pdz-on)) * 1.5rem); }
.pdz-beat small { display: block; font-size: .85rem; letter-spacing: .08em; color: #5c5a75; }
.pdz-beat b { font-size: clamp(1.5rem, 4.5vw, 2.6rem); }
.pdz-fg { --pdz-p: 0; translate: 0 calc(var(--pdz-p) * -30vh); }
.pdz-chip { position: absolute; padding: .5rem 1rem; border-radius: 999px; background: #fff;
font: 600 .85rem system-ui; box-shadow: 0 8px 22px rgba(24, 20, 52, .12); }
.pdz-chip:nth-child(1) { inset-inline-start: 12%; inset-block-start: 24%; }
.pdz-chip:nth-child(2) { inset-inline-end: 10%; inset-block-end: 28%; }
</style>
<!-- RolloutDay.svelte — multi-layer parallax: three speeds, one progress variable -->
<script lang="ts">
import '@nabuxai/ui-core/css';
const beats = [
{ at: '09:15', city: 'Dublin', line: 'One commit starts the story' },
{ at: '11:40', city: 'Singapore', line: 'Canary on 5% of traffic' },
{ at: '16:20', city: 'São Paulo', line: 'Full rollout, nobody on call' },
];
let root: HTMLElement;
// One scroll pass: stage progress against its own rect drives the two
// drifting layers; each beat's brightness is written per element.
$effect(() => {
let frame = 0;
const measure = () => {
frame = 0;
const stage = root.querySelector('.pdz-stage') as HTMLElement;
const nodes = [...root.querySelectorAll('.pdz-beat')] as HTMLElement[];
const centers = nodes.map((_, i) => (i + 0.5) / nodes.length);
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('--pdz-p', p.toFixed(3));
nodes.forEach((beat, i) => {
const on = Math.min(1, Math.max(0, (0.3 - Math.abs(p - centers[i])) / 0.18));
beat.style.setProperty('--pdz-on', on.toFixed(3));
});
};
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="pdz">
<div class="pdz-stage">
<div class="pdz-view">
<div class="pdz-bg" aria-hidden="true"><span>01</span><span>02</span><span>03</span></div>
<div class="pdz-mid">
{#each beats as beat (beat.city)}
<p class="pdz-beat">
<small>{beat.at} · {beat.city}</small>
<b>{beat.line}</b>
</p>
{/each}
</div>
<div class="pdz-fg" aria-hidden="true">
<span class="pdz-chip">+23% deploy frequency</span>
<span class="pdz-chip">99.98% uptime</span>
</div>
</div>
</div>
</div>
<style>
.pdz-stage { block-size: 340vh; }
.pdz-view { position: sticky; inset-block-start: 0; block-size: 100svh; overflow: clip;
display: grid; place-items: center; background: #f4f4fa; }
.pdz-bg, .pdz-fg { position: absolute; inset: 0; pointer-events: none; }
.pdz-bg { --pdz-p: 0; font-weight: 800; font-size: 34vmin; color: rgba(29, 27, 46, .05);
display: flex; justify-content: space-around; align-items: center;
translate: 0 calc(var(--pdz-p) * -8vh); }
.pdz-mid { display: grid; }
.pdz-beat { --pdz-on: 0; grid-area: 1 / 1; margin: 0; text-align: center;
opacity: var(--pdz-on); translate: 0 calc((1 - var(--pdz-on)) * 1.5rem); }
.pdz-beat small { display: block; font-size: .85rem; letter-spacing: .08em; color: #5c5a75; }
.pdz-beat b { font-size: clamp(1.5rem, 4.5vw, 2.6rem); }
.pdz-fg { --pdz-p: 0; translate: 0 calc(var(--pdz-p) * -30vh); }
.pdz-chip { position: absolute; padding: .5rem 1rem; border-radius: 999px; background: #fff;
font: 600 .85rem system-ui; box-shadow: 0 8px 22px rgba(24, 20, 52, .12); }
.pdz-chip:nth-child(1) { inset-inline-start: 12%; inset-block-start: 24%; }
.pdz-chip:nth-child(2) { inset-inline-end: 10%; inset-block-end: 28%; }
</style>