Components / Animations / Scroll Expand
Scroll Expand
A framed panel that opens to full bleed as you scroll past it. JS writes two custom properties and CSS does the rest, so children can join the animation without any wiring.
Model
p = clamp((scroll − start) / (travel·vh), 0, 1)p is written to two CSS variables anything inside can read
Props
| Property | Type | Default | Description |
|---|---|---|---|
media | ReactNode | — | Whatever sits inside the frame — an image, a video, a canvas. |
width | number | 42 | Starting frame width, as a percentage of the viewport. |
height | number | 58 | Starting frame height, as a percentage of the viewport. |
radius | number | 24 | Corner radius at rest, in px. |
endRadius | number | 0 | Corner radius once fully open, in px. |
zoom | number | 1.35 | Scale the media starts pushed in at. |
scrim | number | 0.45 | Peak darkening over the media, 0..1. |
travel | number | 1.2 | Scroll budget, as a multiple of the pinned panel's height. |
hold | number | 0.35 | Fraction of that budget spent held fully open. |
smoothing | number | 0.09 | Per-frame approach rate for the eased value. |
ease | ScrollEase | 'inOut' | Easing of the scroll progress: inOut (cubic), out or linear, or your own function from 0..1 to 0..1. |
onProgress | (progress: number) => void | — | Called with raw progress, 0..1, on every frame it changes. |
children | ReactNode | — | Laid over the panel in the same pinned box, for a heading or caption. The layer lets the pointer through everywhere except on the content itself. |