@mocanvas/state 4.14.0 → 4.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CUSTOM_SHAPES.md +19 -0
- package/MIGRATION.md +1 -1
- package/package.json +1 -1
package/CUSTOM_SHAPES.md
CHANGED
|
@@ -212,6 +212,25 @@ push it out; coming back on screen then costs a style change, not a remount.
|
|
|
212
212
|
`0` unmounts at the viewport edge. A util whose `canCull()` returns `false` is
|
|
213
213
|
never unmounted and never hidden for being off screen.
|
|
214
214
|
|
|
215
|
+
**The zoom in your CSS.** `--mocanvas-zoom` and `--mocanvas-scale` are live on
|
|
216
|
+
the canvas container, but the overlay declares them as constants so that a zoom
|
|
217
|
+
does not restyle every node of every mounted shape — the single largest cost of
|
|
218
|
+
a zoom gesture on a board of DOM cards. A shape whose own CSS reads them says so:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
class CardUtil extends BaseBoxShapeUtil<CardShape> {
|
|
222
|
+
override usesCameraCssVars() {
|
|
223
|
+
return true // this card counter-scales its label
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
That shape then gets the live values on its own wrapper, and its subtree is the
|
|
229
|
+
only one that restyles on a zoom. `options.overlayCameraCssVars: "inherit"`
|
|
230
|
+
turns the mechanism off altogether, for an app that would rather pay than name
|
|
231
|
+
its shapes. Everything outside the overlay — your own chrome, panels, menus —
|
|
232
|
+
reads the live values as before.
|
|
233
|
+
|
|
215
234
|
### `getIndicatorPath` — the selection outline
|
|
216
235
|
|
|
217
236
|
```ts
|
package/MIGRATION.md
CHANGED
|
@@ -273,7 +273,7 @@ it. Two groups are worth knowing about:
|
|
|
273
273
|
|
|
274
274
|
| tldraw token | What you get |
|
|
275
275
|
| --- | --- |
|
|
276
|
-
| `--tl-zoom`, `--tl-scale` | Real values. mocanvas
|
|
276
|
+
| `--tl-zoom`, `--tl-scale` | Real values. mocanvas stamps `--mocanvas-zoom` and `--mocanvas-scale` on the canvas container and restamps them on zoom, so `calc()` rules that hold a constant on-screen size keep working. Inside the DOM overlay they are constants unless the shape's util says `usesCameraCssVars()` — a tldraw shape whose CSS counter-scales with `--tl-scale` needs that line, or `options.overlayCameraCssVars: "inherit"`. |
|
|
277
277
|
| `--tl-color-overlay`, `--tl-color-background-overlay`, `--tl-color-warn` | A static fallback. mocanvas has no equivalent, so these do not follow your theme — set them yourself if they matter. |
|
|
278
278
|
|
|
279
279
|
Everything else maps onto a themed mocanvas variable and follows a theme swap
|
package/package.json
CHANGED