Calm motion: animations on this site only fade, with no movement
InfiniteCanvas
A surface you pan and zoom, with your own things on it
A viewport onto a larger plane: a story board, a flow editor, a map-like diagram, a photo wall. Whatever you put inside is positioned in the canvas' own coordinates and moves and scales with the view. For a list the reader scrolls, use ScrollArea. For a diagram with draggable nodes and links, NodeGraph is built on this.
Board of cards
100% at 40, 40
Intro
Plot
Characters
Ending
- Place children with
position: absolute; left; topin canvas coordinates: the origin is whereview.x, view.yputs it. The canvas needs a height (it fills the width). - Mouse and pen: drag the background to pan (middle button works over children too). The wheel pans, Ctrl+wheel or a trackpad pinch zooms around the pointer,
wheelZoommakes the plain wheel zoom. Touch: one finger pans, two pinch and pan. - Keyboard: focus the canvas, arrows pan (Shift: further), + / − zoom, 0 or Home resets, and the zoom is announced. Keys pressed inside a child belong to the child. Buttons in the corner zoom and reset (
:controls="false"hides them). v-model:viewis{ x, y, zoom }. The exposedfit(rect),centerOn(x, y),zoomBy(factor),reset()andtoWorld(clientX, clientY)drive and read it. Children caninject(blessCanvasKey)for the view andtoWorld.minZoom/maxZoombound the zoom.griddraws a dot grid that moves and scales with the view.
Usage
ts
import { BlessInfiniteCanvas, blessCanvasKey } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
minZoom | number | 0.25 | |
maxZoom | number | 4 | |
grid | boolean | true | draw a dot grid that moves and scales with the view |
controls | boolean | true | the + / − / fit buttons in the corner |
wheelZoom | boolean | — | turn the plain mouse wheel into zoom (otherwise it pans, and Ctrl+wheel or a pinch zooms) |
label | string | "Canvas" | |
labels | Partial<{ zoomIn: string; zoomOut: string; reset: string; zoom: (percent: number) => string; hint: string; }> | — | |
view | CanvasView | { x: 0, y: 0, zoom: 1 } |
Events
| Name | Payload | Description |
|---|---|---|
update:view | [value: CanvasView] |
Slots
| Name | Scope | Description |
|---|---|---|
default | { view: CanvasView; zoom: number; } |
Exposed
| Name | Type | Description |
|---|---|---|
zoomBy | (factor: number, at?: { x: number; y: number; } | undefined) => void | |
reset | () => void | |
fit | (rect: { x: number; y: number; width: number; height: number; }, pad?: number) => void | |
centerOn | (x: number, y: number) => void | |
toWorld | (cx: number, cy: number) => { x: number; y: number; } |