Diorama

Made for a big screen.

This site is one 3D scene, built for a computer: a wide window and a mouse. Open dioramajs.dev on a desktop or a laptop to see it.This site is one 3D scene, built for a wide window. Make this one wider, or open dioramajs.dev on a larger screen.

GitHub

DioramaDocs

bend

PhotoAlso inScroll scenes

@dioramajs/media/bendSource

Scroll speed bends the image like paper and splits its color channels.

View as Markdown
On this page
A snow peak with layered rock bands above a glacier

Live preview needs WebGPU or WebGL 2. A photo of a snow peak with layered rock that bows against the scroll and splits into red and blue fringes while the page moves.

This example failed to draw.

Scroll the page or press Flick the page. The photo bends with the speed of the scroll and straightens as it stops.

Or scroll the page yourself: the faster it moves, the more the photo bows.

Params of bend

Usage

Put it on img, video. start() registers bend, so the attribute alone puts it on an element. The tabs below are the example above, with the values you set.

To change its code, copy the source into your effects folder; the copy replaces the built-in.

Terminal window
npx @dioramajs/diorama add bend
<img
class="peak"
src="/media/portfolio/ice-peak.webp"
width="1600"
height="1067"
data-dio="bend"
/>
import { start } from '@dioramajs/diorama'
const app = start()
app.attach('.peak', 'bend', { strength: 1, split: 1 })
import { start } from '@dioramajs/diorama'
import bend from '@dioramajs/media/bend'
const app = start()
app.attach('.peak', bend({ strength: 1, split: 1 }))

Page transitions

Fades with the page transition. How a flight flies.

Params

Every param is also an attribute, and both app.attach() and the handle take it by name.

ParamTypeDefaultDescription
strengthdata-dio-strengthnumber0 to 31How far the image bows at full scroll speed.
splitdata-dio-splitnumber0 to 31How far the red and blue channels drift apart.

Inputs and frames

It reads velocity . Draws only when you scroll, move the pointer over it or change a param. While the page scrolls and its speed settles; none at rest. How a frame is decided.

Reduced motion and touch

With reduced motion it shows a still frame: motion inputs are zero and time stands still. Runs with scroll velocity held at 0, which shows the image unchanged.

Runs on every device. The same on touch: it follows the scroll.

To change what reduced motion does, patch it in start().

import { start } from '@dioramajs/diorama'
start({ effects: { bend: { reducedMotion: 'off' } } })

Cost and quality

Download
0.5 KB min+gzip the first time a page uses it
GPU
A 32 x 32 grid and three texture reads per pixel.
Memory
The shared texture of the image.
Frames
Idle at rest

It runs from the low tier up. Every tier draws it the same way. The quality plugin picks the tier for each device.

Recipes

Color split only

Set strength to 0 and the image stays flat while its red and blue channels drift apart with the scroll. Stars, city lights and type on a dark ground show the fringes best, so it suits a music or night-event site where a full bend would be too much.

The Milky Way over the night side of the Earth, with a thin band of airglow

Live preview needs WebGPU or WebGL 2. A photo of the Milky Way over the Earth whose stars split into red and blue fringes while the page scrolls.

This example failed to draw.

Or scroll the page yourself: the faster it moves, the more the photo bows.

Params of bend
<img
class="milky-way"
src="/media/festival/milky-way.webp"
width="1400"
height="933"
data-dio="bend"
data-dio-strength="0"
data-dio-split="2"
/>

Bend without the color split

For product photos, where colored fringes look like a printing fault, keep the bend and turn the split off with 0.

<img
src="/img/chair-side.avif"
data-dio="bend"
data-dio-split="0"
/>

A gentle bend for long articles

A reader of a long article scrolls fast through it. Halve both params and the figures still move with the page without pulling the eye away from the text.

<img
src="/img/harbor.avif"
data-dio="bend"
data-dio-strength="0.5"
data-dio-split="0.5"
/>

A showreel strip

bend takes a <video> as well. A muted loop of an agency’s work, set between two sections, bows with the scroll like the photos around it and plays on at rest. A low split keeps the colors of the footage while the page moves.

<video
src="/reel/2026.webm"
poster="/reel/2026.webp"
muted
loop
autoplay
playsinline
data-dio="bend"
data-dio-split="0.4"
></video>

Notes

The bend follows the speed of the scroll, not its position, so an image at rest always matches its HTML. Scrolling from code bends it too, such as a smooth scrollTo() to an anchor or smooth scrolling with Lenis.

The image always bows up and down, the way a page scrolls. A carousel that slides with CSS transforms is not a scroll and leaves its images straight.