# <zoom>

A container whose content pinch-zooms and pans, with zoom commands and live readings.

Category: Layout.

```ham
<column style="w-full gap-12">
    <zoom id="photo"
          max="6"
          double-tap="2"
          zoom-animate="250"
          style="w-full h-300 rounded-xl">
        <img src="https://hypeapps.dev/gallery/assets/city.jpg"
             style="w-full h-full"
             fit="cover"/>
    </zoom>
    <row style="gap-8 items-center">
        <button action="#photo.zoom:2"
                style="bg-teal-600 text-white">Zoom 2×</button>
        <text @text="'zoom ' + $photo.zoom"
              style="muted"></text>
    </row>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/zoom-light.webp), [dark](https://hypeapps.dev/img/tags/zoom-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `double-tap` | A zoom factor a double tap toggles to and back from, about the tap; 0 (the default) does nothing, and the children's own taps are untouched. | `0` |
| `max` | The largest zoom, up to 8. | `8` |
| `min` | The smallest zoom, 1–8. | `1` |
| `rotate` | A two-finger twist turns the content with the pinch, one gesture, about the fingers; false (the default): a twist is ignored, as before. The rotate command always works. | `false` |
| `snap-angle` | Degrees within which a twist snaps to a quarter turn (0, 90, 180, -90); 0 never snaps. | `5` |
| `zoom-animate` | Milliseconds a commanded zoom, rotate or reset glides instead of jumping; a pinch is always direct. | `0` |

## Commands

| Name | What it does |
|---|---|
| `reset` | Back to zoom 1, no pan, no rotation. |
| `rotate` | Turn the content to that angle (-180..180, 0 as laid out), about the center or about a point of the container, which stays put; glides over zoom-animate ms. |
| `zoom` | Zoom to a factor, about the center, or about a point of the container (zoom:2@100,80: logical px from its top left, which stays put). |

## Readings

| Name | What it does |
|---|---|
| `rotation` | The view's rotation in degrees, -180..180 (0 as laid out). |
| `x` | The pan offset: where the content's left edge sits, logical px (0 or negative). |
| `y` | The pan offset of the top edge, logical px. |
| `zoom` | The zoom factor (1 = as laid out). |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<img>`](https://hypeapps.dev/docs/reference/img.md): Shows a picture from a URL or the app's files, sized and cropped by its style.
- [`<row>`](https://hypeapps.dev/docs/reference/row.md): Lays children side by side in one line; flex= shares the free space and align/cross position them.
- [`<button>`](https://hypeapps.dev/docs/reference/button.md): A tappable button that runs an action: a fetch, a navigation or a statement.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<address>`](https://hypeapps.dev/docs/reference/address.md): Contact details as a block, in italic by default, as HTML's address element.
- [`<aside>`](https://hypeapps.dev/docs/reference/aside.md): A side note set apart from the main text, as HTML's aside element; it works like a block.
- [`<background>`](https://hypeapps.dev/docs/reference/background.md): The layer a swiped dismissible row reveals behind it, such as a red delete strip.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
