VelocityCurl
Scroll-velocity skew wrapper β content bends with fling speed, settles with fast-attack/slow-release smoothing.
Live demo
01Playground β fling this page (or the list) and watch the stack bend
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Fling the page β this whole feed bends with your scroll velocity, then exhales back to straight.
Reduced-motion users: the sampler never attaches β this stack stays perfectly still for you (thatβs the point).
Implementation
02<script lang="ts">
import VelocityCurl from '$lib/components/VelocityCurl.svelte';
</script>
β
<VelocityCurl amount={2.5} mode="skew">
<article>Long scrollable content that flexes as you fling it.</article>
</VelocityCurl>VelocityCurl attaches one passive scroll listener and, while scrolling, runs a single rAF loop: velocity = |ΞscrollY|/Ξt with Ξt clamped (1/240s..0.1s) so background-tab wakeups cannot spike. The signal is smoothed asymmetrically β 25ms attack so a fling registers instantly, 175ms release so the settle breathes β and written to a single CSS custom property that drives a GPU-composited skewY (or rotateX) transform. At rest the loop cancels itself; with prefers-reduced-motion the listener is never even attached.
Logic explainer
03What Does It Do? (Plain English)
Wrap any content and it gently bends with scroll speed β fling the page and the content skews a degree or two, then settles back smoothly, like paper reacting to air. It makes scrolling feel physical without touching layout.
How It Works (Pseudo-Code)
on scroll event: wake the rAF loop (passive listener, zero cost at rest)
each frame:
velocity = |ΞscrollY| / Ξt (Ξt clamped 1/240s..0.1s)
activity β attack-fast / release-slow exponential smoothing
write --velocity-curl (0..amount) to the wrapper
when activity < Ξ΅: write 0, cancel rAF, go idle
reduced motion: never start; the wrapper applies no transform at allThe Attack/Release Curve
A raw velocity signal is unusable β trackpads emit tiny spikes that read as jitter. The sampler uses asymmetric time constants: attack Οβ25ms (a real fling registers instantly), release Οβ175ms (the settle is a slow exhale). The visible transform is a single CSS custom property driving skewY (or rotateX with perspective), so the browser composites it on the GPU.
State Flow Diagram
resting ββscroll eventβββΆ sampling (rAF, writes --velocity-curl)
β² β
βββ activity < epsilon βββββ
reduced motion: resting forever (no listener, no transform)Props Reference
| Prop | Type | Default | Description |
|---|---|---|---|
| amount | number |
2 |
Maximum bend in degrees |
| mode | 'skew' | 'rotateX' |
'skew' |
Bend style |
| attack | number |
0.025 |
Attack time constant (s) |
| release | number |
0.175 |
Release time constant (s) |
| disabledBelow | number |
0.02 |
Activity epsilon for idling |
| class | string |
'' |
Extra classes |
Edge Cases
- Background tabs: dt clamping means a minute-long sleep can't spike the value on wake.
- Reduced motion: the scroll listener is never even attached.
- Nested scrollers: the sampler reads
window.scrollYβ for a nested scroller, wrap that scroller's content and scroll its container (or fork the sampler to take a ref). - Compositor cost: one
will-change: transformwhile active; released when idle.
Dependencies
Zero. rAF + one passive scroll listener + a CSS custom property.
File Structure
src/lib/components/VelocityCurl.svelte β component (sampler exported from module script)
src/lib/components/VelocityCurl.md β this doc
src/lib/components/VelocityCurl.test.ts β 6 sampler unit tests
src/routes/velocitycurl/+page.svelte β demo (skew/rotateX playground)