Kinetic type
JS behaviour
Velocity band
Two oversized text bands that take speed and direction from your scroll: a flick sends them racing, a pause calms them and scrolling up drives them in reverse; the bands run against each other and keep the right direction under RTL.
Real scenarios
The component as it is used in a product — not a specimen grid.
Important props
| Prop | Type | Default | What it does |
|---|---|---|---|
| velocity | px/frame | 'Δscroll × .35' | Scroll acceleration lands straight on the band speed; the negative sign (scrolling up) reverses the direction. |
| damping | per frame | '.92' | When you pause, the speed decays back to its calm base; flicks bleed off here too. |
| direction | ±1 | 'opposite pair' | The two bands run against each other; pixel math and modulo keep the direction right in RTL exactly as in LTR. |
| wrap | modulo | 'half track' | The track is two glued halves that wrap seamlessly — infinity without an infinite DOM. |
Snippet
{{-- resources/views/demos/components/kinetic/velocity-band.blade.php --}}
<div class="vbnd" x-data="{
pos: [0, 0], vel: [0, 0], last: null, raf: 0, io: null, mq: null, onMq: null, visible: true,
get tracks() { return [this.$refs.trackA, this.$refs.trackB]; },
onScroll(e) {
const y = e.target.scrollTop;
const dv = this.last === null ? 0 : y - this.last;
this.last = y;
this.vel[0] += dv * 0.35; // flick = jump, pause = calm
this.vel[1] -= dv * 0.35; // the second band mirrors it
},
frame() {
this.tracks.forEach((t, k) => {
this.vel[k] = this.vel[k] * 0.92 + (k ? -0.6 : 0.6); // decay to base
const half = t.scrollWidth / 2;
this.pos[k] = ((this.pos[k] + this.vel[k]) % half + half) % half; // seamless wrap
t.style.transform = `translateX(${(-this.pos[k]).toFixed(1)}px)`;
});
this.raf = requestAnimationFrame(() => this.frame());
},
run() {
cancelAnimationFrame(this.raf);
if (this.mq.matches || !this.visible) return;
this.raf = requestAnimationFrame(() => this.frame());
},
init() {
this.mq = matchMedia('(prefers-reduced-motion: reduce)');
this.onMq = () => this.run();
this.mq.addEventListener('change', this.onMq);
this.io = new IntersectionObserver((e) => { this.visible = e[0].isIntersecting; this.run(); });
this.io.observe(this.$el);
this.run();
},
destroy() {
cancelAnimationFrame(this.raf);
if (this.io) this.io.disconnect();
if (this.mq && this.onMq) this.mq.removeEventListener('change', this.onMq);
},
}">
<div class="vbnd-scroll" x-ref="scroller" x-on:scroll.passive="onScroll">
<p class="vbnd-story">Release notes 4.2 — …</p>
</div>
<div class="vbnd-band"><div class="vbnd-track" x-ref="trackA">
<span>NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · </span><span aria-hidden="true">NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · </span>
</div></div>
<div class="vbnd-band" data-rev><div class="vbnd-track" x-ref="trackB">
<span>SCROLL HARDER · BAND FASTER · </span><span aria-hidden="true">SCROLL HARDER · BAND FASTER · </span>
</div></div>
</div>
<style>
.vbnd-scroll { block-size: 11rem; overflow-y: auto; border: 1px solid #e7e5e4; border-radius: 1rem; }
.vbnd-band { overflow: clip; border-block: 1px solid #e7e5e4;
font: 900 clamp(1.6rem, 5vw, 3rem)/1.2 'IBM Plex Sans', sans-serif; }
.vbnd-track { display: flex; inline-size: max-content; will-change: transform; }
.vbnd-track span { white-space: nowrap; padding-inline: .2em; }
.vbnd-band[data-rev] { color: #7c3aed; }
</style>
// app/Pages/Changelog.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 VelocityBand from '@/components/VelocityBand';
export default function Changelog() {
return (
<NabuXUIProvider locale="en" linkComponent={Link}>
<main className="nx-page">
<VelocityBand />
</main>
</NabuXUIProvider>
);
}
// VelocityBand.jsx — marquee bands driven by the reader's scroll velocity
import { useEffect, useRef } from 'react';
import '@nabuxai/ui-core/css';
const A = 'NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · ';
const B = 'SCROLL HARDER · BAND FASTER · ';
export default function VelocityBand() {
const scroller = useRef(null);
const tracks = useRef([]);
useEffect(() => {
const pos = [0, 0], vel = [0, 0];
let last = null, raf = 0;
const mq = matchMedia('(prefers-reduced-motion: reduce)');
const onScroll = () => {
const dv = last === null ? 0 : scroller.current.scrollTop - last;
last = scroller.current.scrollTop;
vel[0] += dv * 0.35; // flick = jump
vel[1] -= dv * 0.35; // the mirror band
};
const frame = () => {
tracks.current.forEach((t, k) => {
if (!t) return;
vel[k] = vel[k] * 0.92 + (k ? -0.6 : 0.6); // decay to calm base
const half = t.scrollWidth / 2;
pos[k] = ((pos[k] + vel[k]) % half + half) % half; // seamless wrap
t.style.transform = `translateX(${(-pos[k]).toFixed(1)}px)`;
});
raf = requestAnimationFrame(frame);
};
const run = () => { cancelAnimationFrame(raf); if (!mq.matches) raf = requestAnimationFrame(frame); };
scroller.current.addEventListener('scroll', onScroll, { passive: true });
mq.addEventListener('change', run);
const io = new IntersectionObserver(([e]) => (e.isIntersecting ? run() : cancelAnimationFrame(raf)));
io.observe(scroller.current);
run();
return () => {
scroller.current?.removeEventListener('scroll', onScroll);
mq.removeEventListener('change', run);
io.disconnect(); cancelAnimationFrame(raf);
};
}, []);
const track = (html, k) => (
<div className="vbnd-track" ref={(el) => (tracks.current[k] = el)}>
<span>{html}</span><span aria-hidden="true">{html}</span>
</div>
);
return (
<>
<style>{`
.vbnd-scroll { block-size: 11rem; overflow-y: auto; padding: 1rem;
border: 1px solid #e7e5e4; border-radius: 1rem; }
.vbnd-band { overflow: clip; border-block: 1px solid #e7e5e4;
font: 900 clamp(1.6rem, 5vw, 3rem)/1.2 'IBM Plex Sans', sans-serif; }
.vbnd-track { display: flex; inline-size: max-content; will-change: transform; }
.vbnd-track span { white-space: nowrap; padding-inline: .2em; }
.vbnd-band[data-rev] { color: #7c3aed; }
`}</style>
<div className="vbnd-scroll" ref={scroller}>
<p>Release notes 4.2 — the motion tokens ship, the type scale tightens…</p>
</div>
<div className="vbnd-band">{track(A, 0)}</div>
<div className="vbnd-band" data-rev>{track(B, 1)}</div>
</>
);
}
<!-- VelocityBand.vue — marquee bands driven by the reader's scroll velocity -->
<script setup>
import { onBeforeUnmount, onMounted, ref } from 'vue';
import '@nabuxai/ui-core/css';
const scroller = ref(null);
const tracks = ref([]);
const pos = [0, 0], vel = [0, 0];
let last = null, raf = 0, io = null;
const mq = matchMedia('(prefers-reduced-motion: reduce)');
function onScroll() {
const dv = last === null ? 0 : scroller.value.scrollTop - last;
last = scroller.value.scrollTop;
vel[0] += dv * 0.35; // flick = jump
vel[1] -= dv * 0.35; // the mirror band
}
function frame() {
tracks.value.forEach((t, k) => {
vel[k] = vel[k] * 0.92 + (k ? -0.6 : 0.6); // decay to calm base
const half = t.scrollWidth / 2;
pos[k] = ((pos[k] + vel[k]) % half + half) % half; // seamless wrap
t.style.transform = `translateX(${(-pos[k]).toFixed(1)}px)`;
});
raf = requestAnimationFrame(frame);
}
function run() { cancelAnimationFrame(raf); if (!mq.matches) raf = requestAnimationFrame(frame); }
onMounted(() => {
scroller.value.addEventListener('scroll', onScroll, { passive: true });
mq.addEventListener('change', run);
io = new IntersectionObserver(([e]) => (e.isIntersecting ? run() : cancelAnimationFrame(raf)));
io.observe(scroller.value);
run();
});
onBeforeUnmount(() => {
scroller.value?.removeEventListener('scroll', onScroll);
mq.removeEventListener('change', run);
io?.disconnect(); cancelAnimationFrame(raf);
});
</script>
<template>
<div class="vbnd-scroll" ref="scroller">
<p>Release notes 4.2 — the motion tokens ship, the type scale tightens…</p>
</div>
<div class="vbnd-band">
<div class="vbnd-track" ref="(el) => (tracks[0] = el)">
<span>NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · </span><span aria-hidden="true">NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · </span>
</div>
</div>
<div class="vbnd-band" data-rev>
<div class="vbnd-track" ref="(el) => (tracks[1] = el)">
<span>SCROLL HARDER · BAND FASTER · </span><span aria-hidden="true">SCROLL HARDER · BAND FASTER · </span>
</div>
</div>
</template>
<style scoped>
.vbnd-scroll { block-size: 11rem; overflow-y: auto; padding: 1rem;
border: 1px solid #e7e5e4; border-radius: 1rem; }
.vbnd-band { overflow: clip; border-block: 1px solid #e7e5e4;
font: 900 clamp(1.6rem, 5vw, 3rem)/1.2 'IBM Plex Sans', sans-serif; }
.vbnd-track { display: flex; inline-size: max-content; will-change: transform; }
.vbnd-track span { white-space: nowrap; padding-inline: .2em; }
.vbnd-band[data-rev] { color: #7c3aed; }
</style>
<!-- VelocityBand.svelte — marquee bands driven by the reader's scroll velocity -->
<script>
import { onMount } from 'svelte';
import '@nabuxai/ui-core/css';
let scroller;
let tracks = [];
const pos = [0, 0], vel = [0, 0];
let last = null, raf = 0, io = null;
const mq = matchMedia('(prefers-reduced-motion: reduce)');
function onScroll() {
const dv = last === null ? 0 : scroller.scrollTop - last;
last = scroller.scrollTop;
vel[0] += dv * 0.35; // flick = jump
vel[1] -= dv * 0.35; // the mirror band
}
function frame() {
tracks.forEach((t, k) => {
vel[k] = vel[k] * 0.92 + (k ? -0.6 : 0.6); // decay to calm base
const half = t.scrollWidth / 2;
pos[k] = ((pos[k] + vel[k]) % half + half) % half; // seamless wrap
t.style.transform = `translateX(${(-pos[k]).toFixed(1)}px)`;
});
raf = requestAnimationFrame(frame);
}
function run() { cancelAnimationFrame(raf); if (!mq.matches) raf = requestAnimationFrame(frame); }
onMount(() => {
scroller.addEventListener('scroll', onScroll, { passive: true });
mq.addEventListener('change', run);
io = new IntersectionObserver(([e]) => (e.isIntersecting ? run() : cancelAnimationFrame(raf)));
io.observe(scroller);
run();
return () => {
scroller?.removeEventListener('scroll', onScroll);
mq.removeEventListener('change', run);
io?.disconnect(); cancelAnimationFrame(raf);
};
});
</script>
<div class="vbnd-scroll" bind:this={scroller}>
<p>Release notes 4.2 — the motion tokens ship, the type scale tightens…</p>
</div>
<div class="vbnd-band">
<div class="vbnd-track" bind:this={tracks[0]}>
<span>NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · </span><span aria-hidden="true">NABUXUI · KINETIC TYPE · FEEL THE VELOCITY · </span>
</div>
</div>
<div class="vbnd-band" data-rev>
<div class="vbnd-track" bind:this={tracks[1]}>
<span>SCROLL HARDER · BAND FASTER · </span><span aria-hidden="true">SCROLL HARDER · BAND FASTER · </span>
</div>
</div>
<style>
.vbnd-scroll { block-size: 11rem; overflow-y: auto; padding: 1rem;
border: 1px solid #e7e5e4; border-radius: 1rem; }
.vbnd-band { overflow: clip; border-block: 1px solid #e7e5e4;
font: 900 clamp(1.6rem, 5vw, 3rem)/1.2 'IBM Plex Sans', sans-serif; }
.vbnd-track { display: flex; inline-size: max-content; will-change: transform; }
.vbnd-track span { white-space: nowrap; padding-inline: .2em; }
.vbnd-band[data-rev] { color: #7c3aed; }
</style>