# bend

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

While the page scrolls the image bows against the motion, like paper dragged through air, and its red and blue channels drift apart. It straightens as the scroll slows, so at rest the copy matches the image.

Module `media`, category Photo. Import `@dioramajs/media/bend`. [Source](https://github.com/MasterKurosava/diorama/blob/main/packages/media/src/bend.ts)

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.

```html title="index.html"
<img class="peak" src="/media/portfolio/ice-peak.webp" alt="A snow peak with layered rock bands above a glacier" width="1600" height="1067" data-dio="bend" />
```

## Usage

Put it on: img, video.

`start()` registers `bend`, so the attribute alone puts it on an element.

```html
<img src="/photo.avif" alt="" data-dio="bend" />
```

In page transitions: Fades with the page transition.

## Params

| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `strength` | `data-dio-strength` | `number` 0 to 3 | `1` | How far the image bows at full scroll speed. |
| `split` | `data-dio-split` | `number` 0 to 3 | `1` | How far the red and blue channels drift apart. |

## Inputs and frames

Reads [`velocity`](/docs/api/inputs#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. See [how a frame is decided](/docs/concepts/frames).

## 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.

```ts
import { start } from '@dioramajs/diorama'

start({ effects: { bend: { reducedMotion: 'off' } } })
```

## Cost and quality

Loads 0.5 KB 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.

See [the quality plugin](/docs/effects/quality).

## 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.

A photo of the Milky Way over the Earth whose stars split into red and blue fringes while the page scrolls.

```html title="index.html"
<img class="milky-way" src="/media/festival/milky-way.webp" alt="The Milky Way over the night side of the Earth, with a thin band of airglow" width="1400" height="933" data-dio="bend" data-dio-strength="0" data-dio-split="2" />
```

```html title="panel.html"
<button type="button" data-flick>Flick the page</button>
<p>Or scroll the page yourself: the faster it moves, the more the photo bows.</p>
```

```ts title="script.ts"
import { mountFlick } from '../_flick.ts'

export default mountFlick
```

### 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.

```html
<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.

```html
<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.

```html
<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.

## Related

- [compare](/docs/effects/compare.md): Two pictures in one box, before and after, split by a line you drag, hover or scroll.
- [flare](/docs/effects/flare.md): A lens flare or a glossy light sweep over a photo that follows the pointer or the scroll.
- [frost](/docs/effects/frost.md): Frosted glass over a photo, or over the whole page, that the pointer wipes clear and that slowly fogs back.
- [glitch](/docs/effects/glitch.md): A digital glitch in short bursts: blocks slide sideways, color channels split, scanlines flicker.
- [image](/docs/effects/image.md): Draws the image or video unchanged, as a GL copy that page flights and other effects build on.
- [liquid](/docs/effects/liquid.md): The pointer leaves a fluid trail on a photo that settles back like water.
- [parallax](/docs/effects/parallax.md): The image drifts inside its frame with the pointer and the scroll; with a depth map, in 2.5D.
- [pixelate](/docs/effects/pixelate.md): The image resolves from big pixels to sharp as it scrolls into view, or breaks into pixels on hover.
- [How a layer follows scroll](/docs/concepts/scroll.md)
- [Reduced motion](/docs/guides/reduced-motion.md)
