@loadmap/react 0.13.0 → 0.15.0
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/README.md +6 -0
- package/dist/{Loadmap-ChdKkdGE.d.ts → Loadmap-DmcFVIQF.d.ts} +89 -3
- package/dist/{Loadmap-C03XTQqu.js → Loadmap-GwoYUby3.js} +1301 -1706
- package/dist/index.d.ts +10 -4
- package/dist/index.js +3 -3
- package/dist/later-ChRpEoLJ.js +491 -0
- package/dist/source.d.ts +1 -1
- package/dist/source.js +1 -1
- package/dist/zoom-C_qebdpE.js +609 -0
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -98,6 +98,12 @@ step changes, the change, and the whole diagram again for the step's `seconds`,
|
|
|
98
98
|
once it is past the target. With reduced motion the camera cuts and the ring holds still. `ref.playStory()` plays it
|
|
99
99
|
on the engine's clock, which `step()` advances.
|
|
100
100
|
|
|
101
|
+
`zoom` lets the reader pan and zoom the diagram: a drag pans (a press that hardly moves still clicks a box), a pinch
|
|
102
|
+
or the wheel with Ctrl or ⌘ zooms about the pointer, the keys + − 0 and the arrows work on the focused board, and the
|
|
103
|
+
buttons on it go − · zoom · + · Fit. A page that scrolls keeps its plain wheel. `<Diagram lm={lm} canvas={{ left: 420
|
|
104
|
+
}} />` fills its container as a canvas the wheel alone zooms; the insets are what the page floats over it, and Fit
|
|
105
|
+
frames the diagram in the rest. Pictures and recordings always show the whole diagram, whatever the reader's view.
|
|
106
|
+
|
|
101
107
|
`useLoadmap` with `LoadmapRoot`, `Diagram`, `Verdict`, `Limits`, `Controls` and the others builds a page of your own
|
|
102
108
|
layout from the same pieces. The diagram's Full screen takes the whole root: inside a `<div className="lm-side">`
|
|
103
109
|
after the `Diagram`, your pieces become a box below it that scrolls on its own; a title, the `Scenarios` and the
|
|
@@ -18,6 +18,70 @@ interface Shapes {
|
|
|
18
18
|
to: string;
|
|
19
19
|
}[];
|
|
20
20
|
}
|
|
21
|
+
/** What the reader looks at: the scene point at the board's centre, and how many board pixels a scene unit takes. */
|
|
22
|
+
interface Viewpoint {
|
|
23
|
+
x: number;
|
|
24
|
+
y: number;
|
|
25
|
+
k: number;
|
|
26
|
+
}
|
|
27
|
+
/** Pixels on each side of the board that something floats over: Fit frames the diagram in what is left. */
|
|
28
|
+
interface Insets {
|
|
29
|
+
top: number;
|
|
30
|
+
right: number;
|
|
31
|
+
bottom: number;
|
|
32
|
+
left: number;
|
|
33
|
+
}
|
|
34
|
+
/** The board in pixels, the part of it that is free, and how Fit uses it. */
|
|
35
|
+
interface Viewport {
|
|
36
|
+
w: number;
|
|
37
|
+
h: number;
|
|
38
|
+
inset: Insets;
|
|
39
|
+
/** Room Fit leaves around the diagram, in pixels. */
|
|
40
|
+
margin: number;
|
|
41
|
+
/** The closest Fit comes, in board pixels a scene unit. */
|
|
42
|
+
fitMax: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The reader's view of a board that pans and zooms: the board in pixels with what floats over it, and where the reader
|
|
46
|
+
* has moved. It comes with the code that pans and zooms, so a page that never zooms does not load it; the engine asks
|
|
47
|
+
* it what part of the scene to show.
|
|
48
|
+
*/
|
|
49
|
+
declare class Viewer {
|
|
50
|
+
#private;
|
|
51
|
+
readonly engine: Engine;
|
|
52
|
+
viewport: Viewport;
|
|
53
|
+
constructor(engine: Engine, viewport: Viewport);
|
|
54
|
+
/** The board changed size or what floats over it; a reader's view stays, kept in sight. */
|
|
55
|
+
setViewport(vp: Viewport): void;
|
|
56
|
+
/** The view Fit gives: the whole diagram in the free part of the board. Null while nothing is drawn. */
|
|
57
|
+
fit(): Viewpoint | null;
|
|
58
|
+
/** The reader's own view; null while the diagram stays fitted. */
|
|
59
|
+
get readerView(): Viewpoint | null;
|
|
60
|
+
/** What the board shows now, the story's camera included. */
|
|
61
|
+
shownView(): Viewpoint | null;
|
|
62
|
+
/** The zoom's range, in board pixels a scene unit. */
|
|
63
|
+
zoomRange(): {
|
|
64
|
+
min: number;
|
|
65
|
+
max: number;
|
|
66
|
+
} | null;
|
|
67
|
+
/**
|
|
68
|
+
* The reader's view, kept in the zoom's range and with the diagram in sight; null fits it again, and keeps it fitted
|
|
69
|
+
* as the board changes. A story playing stops where it is: the reader took the view.
|
|
70
|
+
*/
|
|
71
|
+
setView(v: Viewpoint | null): void;
|
|
72
|
+
/** The part of the scene the board shows now: its viewBox. */
|
|
73
|
+
box(): Rect | null;
|
|
74
|
+
/** Where the board draws the scene now, in its pixels: its scale and offset. */
|
|
75
|
+
placement(): {
|
|
76
|
+
k: number;
|
|
77
|
+
dx: number;
|
|
78
|
+
dy: number;
|
|
79
|
+
} | null;
|
|
80
|
+
/** Play starts: the camera the first shot flies from, where the reader had moved; the view is the story's now. */
|
|
81
|
+
lead(): Rect | undefined;
|
|
82
|
+
/** Paints the dots on the board's canvas where the SVG draws their places: in the board's pixels, then the canvas's. */
|
|
83
|
+
paint(ctx: CanvasRenderingContext2D, canvas: HTMLCanvasElement): void;
|
|
84
|
+
}
|
|
21
85
|
/** A dot as it is drawn now, in scene units. */
|
|
22
86
|
interface Dot {
|
|
23
87
|
x: number;
|
|
@@ -101,6 +165,10 @@ declare class Engine {
|
|
|
101
165
|
reducedMotion: boolean;
|
|
102
166
|
/** The part of the scene the board shows while the story plays; null for all of it. */
|
|
103
167
|
camera: Rect | null;
|
|
168
|
+
/** The reader's view of a board they pan and zoom; null where the board only shows what the camera frames. */
|
|
169
|
+
viewer: Viewer | null;
|
|
170
|
+
/** Changes with what the board shows: the zoom controls and a box's detail follow it. */
|
|
171
|
+
viewId: number;
|
|
104
172
|
/** What the diagram says about the step the story plays; null when it does not play. */
|
|
105
173
|
cue: Cue | null;
|
|
106
174
|
host: StoryHost | null;
|
|
@@ -151,8 +219,13 @@ declare class Engine {
|
|
|
151
219
|
shot: Shot;
|
|
152
220
|
t: number;
|
|
153
221
|
} | null;
|
|
154
|
-
/**
|
|
222
|
+
/**
|
|
223
|
+
* Points the SVG at what the board shows: the camera, under the reader's view where they pan and zoom. React draws the
|
|
224
|
+
* whole scene's viewBox; this replaces it after each render.
|
|
225
|
+
*/
|
|
155
226
|
applyCamera(): void;
|
|
227
|
+
/** What the board shows changed: the zoom controls and a box's detail follow. */
|
|
228
|
+
changed(): void;
|
|
156
229
|
/** Draws the dots on the overlay canvas and the worker fills in the SVG. */
|
|
157
230
|
draw(o?: {
|
|
158
231
|
particles?: boolean;
|
|
@@ -172,6 +245,8 @@ declare class Engine {
|
|
|
172
245
|
* go where the SVG shows their places (its viewBox, centred where its shape differs), so they keep matching the bars.
|
|
173
246
|
*/
|
|
174
247
|
paintParticles(ctx: CanvasRenderingContext2D, scale: number): void;
|
|
248
|
+
/** The dots in scene units, on a context already transformed to the scene. */
|
|
249
|
+
paintDots(ctx: CanvasRenderingContext2D): void;
|
|
175
250
|
}
|
|
176
251
|
interface LoadmapOptions<P> extends SimOptions {
|
|
177
252
|
/** Values to start from instead of the model's defaults. */
|
|
@@ -180,7 +255,10 @@ interface LoadmapOptions<P> extends SimOptions {
|
|
|
180
255
|
elk?: ElkEngine;
|
|
181
256
|
/** Below this container width the diagram is laid out top to bottom. Default 640. */
|
|
182
257
|
narrowBelow?: number;
|
|
183
|
-
/**
|
|
258
|
+
/**
|
|
259
|
+
* Which way the diagram runs where there is room. Default: from its shape (`directionOf`), right unless its widest
|
|
260
|
+
* layer has more boxes than its longest chain; below `narrowBelow` it is always DOWN.
|
|
261
|
+
*/
|
|
184
262
|
direction?: Direction;
|
|
185
263
|
/** What full screen opens with: the panels around the diagram, or mainly the diagram and the story. Default panels. */
|
|
186
264
|
fullScreenMode?: FullScreenMode;
|
|
@@ -190,6 +268,12 @@ interface LoadmapOptions<P> extends SimOptions {
|
|
|
190
268
|
* layout follows the frame's size as full screen follows the screen's.
|
|
191
269
|
*/
|
|
192
270
|
fill?: boolean;
|
|
271
|
+
/**
|
|
272
|
+
* The reader can pan and zoom the diagram: drag it, pinch it, the keys + − 0 and the arrows, and the zoom buttons on
|
|
273
|
+
* the board. The wheel zooms with Ctrl or ⌘ held, so the page keeps its scroll; a `<Diagram canvas>` that fills a
|
|
274
|
+
* page of its own zooms with the wheel alone. Pictures and recordings show the whole diagram whatever the view.
|
|
275
|
+
*/
|
|
276
|
+
zoom?: boolean;
|
|
193
277
|
/**
|
|
194
278
|
* Seconds the diagram takes to move to a new structure (a scenario, a story step or a control that adds pods): what
|
|
195
279
|
* stays moves, what is new fades in. 0 cuts. Default 0.8; with reduced motion it always cuts. The load never moves it.
|
|
@@ -231,6 +315,8 @@ interface LoadmapController<P = any> {
|
|
|
231
315
|
fullScreen: boolean;
|
|
232
316
|
/** The root fills its container as full screen does, for good. */
|
|
233
317
|
fill: boolean;
|
|
318
|
+
/** The reader can pan and zoom the diagram. */
|
|
319
|
+
zoom: boolean;
|
|
234
320
|
toggleFullScreen: () => void;
|
|
235
321
|
/** What full screen shows. The reader switches it; the page picks where it starts. */
|
|
236
322
|
fullScreenMode: FullScreenMode;
|
|
@@ -320,4 +406,4 @@ interface LoadmapProps<P> extends LoadmapOptions<P> {
|
|
|
320
406
|
/** The whole page piece: scenarios, diagram, verdict, headroom, live meters, limits, controls and assumptions. */
|
|
321
407
|
declare function Loadmap<P>({ model, view, theme, title, assumptions, headroom, compare, fullScreen, onNodeClick, selected, ref, ...o }: LoadmapProps<P>): import("react").JSX.Element;
|
|
322
408
|
declare function handleOf(lm: LoadmapController): LoadmapHandle;
|
|
323
|
-
export { LoadmapProps as a, handleOf as c, LoadmapController as d, LoadmapOptions as f, Engine as g, Dot as h, LoadmapPanel as i, usePageTheme as l, Cue as m, Loadmap as n, LoadmapRoot as o, useLoadmap as p, LoadmapHandle as r, Theme as s, LOADMAP_PANELS as t, FullScreenMode as u };
|
|
409
|
+
export { Insets as _, LoadmapProps as a, handleOf as c, LoadmapController as d, LoadmapOptions as f, Engine as g, Dot as h, LoadmapPanel as i, usePageTheme as l, Cue as m, Loadmap as n, LoadmapRoot as o, useLoadmap as p, LoadmapHandle as r, Theme as s, LOADMAP_PANELS as t, FullScreenMode as u };
|