bend
Scroll speed bends the image like paper and splits its color channels.
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.
Or scroll the page yourself: the faster it moves, the more the photo bows.
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.
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.
| Param | Type | Default | Description |
|---|---|---|---|
strengthdata-dio-strength | number0 to 3 | 1 | How far the image bows at full scroll speed. |
splitdata-dio-split | number0 to 3 | 1 | How 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.
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.
<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.