@jsb188/gfx 1.1.2 → 1.1.11

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.
Files changed (56) hide show
  1. package/README.md +54 -248
  2. package/libs/dotGrid.ts +77 -480
  3. package/libs/effects/effectQuad.ts +2 -8
  4. package/libs/pointer.ts +0 -6
  5. package/libs/runtime.ts +4 -6
  6. package/libs/types.ts +1 -8
  7. package/main.ts +0 -2
  8. package/modules/Carousel.helpers.ts +0 -234
  9. package/modules/Carousel.tsx +29 -135
  10. package/modules/DotsArea.tsx +120 -0
  11. package/modules/GfxCanvas.tsx +2 -10
  12. package/modules/ScrollSteps.tsx +52 -7
  13. package/modules/VisionBoard.helpers.ts +561 -0
  14. package/modules/VisionBoard.tsx +358 -0
  15. package/modules/VisionBoard.types.ts +88 -0
  16. package/package.json +5 -15
  17. package/scenes/Carousel.ts +18 -99
  18. package/scenes/DotsArea.ts +208 -0
  19. package/tsconfig.json +1 -1
  20. package/utils/color.ts +2 -64
  21. package/utils/dotGridSpecs.ts +46 -304
  22. package/elements/Shapes.helpers.ts +0 -204
  23. package/elements/Shapes.hooks.ts +0 -171
  24. package/elements/Shapes.tsx +0 -505
  25. package/elements/Shapes.types.ts +0 -81
  26. package/elements/Stack.helpers.ts +0 -42
  27. package/elements/Stack.tsx +0 -143
  28. package/elements/Text.helpers.ts +0 -45
  29. package/elements/Text.hooks.ts +0 -197
  30. package/elements/Text.tsx +0 -98
  31. package/libs/dotGrid.helpers.ts +0 -53
  32. package/libs/effects/dotEffects.ts +0 -136
  33. package/modules/Carousel.hooks.ts +0 -520
  34. package/modules/Dots.tsx +0 -269
  35. package/modules/DotsBoard.helpers.ts +0 -388
  36. package/modules/DotsBoard.hooks.ts +0 -144
  37. package/modules/DotsBoard.strings.ts +0 -649
  38. package/modules/DotsBoard.types.ts +0 -240
  39. package/modules/DotsBoardCanvas.hooks.ts +0 -49
  40. package/modules/DotsBoardCanvas.tsx +0 -190
  41. package/modules/DotsBoardElements.tsx +0 -330
  42. package/modules/Gallery.helpers.ts +0 -32
  43. package/modules/Gallery.hooks.ts +0 -149
  44. package/modules/Gallery.tsx +0 -194
  45. package/modules/KineticHeader.helpers.ts +0 -44
  46. package/modules/KineticHeader.hooks.ts +0 -206
  47. package/modules/KineticHeader.tsx +0 -305
  48. package/modules/KineticHeader.types.ts +0 -56
  49. package/modules/ScrollSteps.hooks.ts +0 -138
  50. package/scenes/DotsBoard.helpers.ts +0 -12
  51. package/scenes/DotsBoard.ts +0 -245
  52. package/utils/align.ts +0 -18
  53. package/utils/dotEffectSpecs.ts +0 -79
  54. package/utils/motion.ts +0 -88
  55. package/utils/random.ts +0 -22
  56. package/utils/strings.ts +0 -116
@@ -0,0 +1,561 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type {
3
+ ResolvedVisionBoardItem,
4
+ VisionBoardConnection,
5
+ VisionBoardItem,
6
+ VisionBoardOverrides,
7
+ VisionBoardSegment,
8
+ VisionBoardSpring,
9
+ VisionBoardTextPlacement,
10
+ } from './VisionBoard.types.ts';
11
+
12
+ /**
13
+ * Constants
14
+ */
15
+
16
+ export const VISION_BOARD_DEFAULTS = {
17
+ nodeSize: 56,
18
+ textWidth: 160,
19
+ textGap: 12,
20
+ dragLimit: 120,
21
+ /** Extra room past `dragLimit`, as a fraction of it, that the rubber band asymptotically allows. */
22
+ dragStretch: 0.5,
23
+ /** Fraction of its drag velocity an item keeps when released. */
24
+ throwFactor: 0.5,
25
+ slack: 0.12,
26
+ stringWidth: 1.5,
27
+ itemSpring: { stiffness: 180, damping: 16 } as VisionBoardSpring,
28
+ stringSpring: { stiffness: 140, damping: 10 } as VisionBoardSpring,
29
+ /** Fade and shrink of an item that hides or shows, in ms. */
30
+ hideMs: 350,
31
+ };
32
+
33
+ const PHYSICS = {
34
+ /** Longest frame the springs integrate; a background tab resuming does not explode. */
35
+ maxDt: 1 / 30,
36
+ /** Springs integrate in sub-steps no longer than this, which keeps stiff settings stable. */
37
+ subStep: 1 / 120,
38
+ /** A body within this many board units of its target, moving slower than `settleVelocity`, snaps to rest. */
39
+ settleDistance: 0.05,
40
+ settleVelocity: 1,
41
+ /** A pointer still for longer than this before release throws nothing. */
42
+ staleDragMs: 100,
43
+ };
44
+
45
+ /**
46
+ * Resolution
47
+ */
48
+
49
+ /*
50
+ * Apply the overrides and the tag filter to the items. Ids default to the index. With
51
+ * `visibleTags`, a tagged item shows only if it carries at least one of them; untagged items
52
+ * (hubs, labels) are never filtered.
53
+ */
54
+ export function resolveVisionBoardItems(
55
+ items: VisionBoardItem[],
56
+ overrides?: VisionBoardOverrides,
57
+ visibleTags?: string[] | null,
58
+ ): ResolvedVisionBoardItem[] {
59
+ return items.map((item, index) => {
60
+ const id = item.id ?? String(index);
61
+ const override = overrides?.[id];
62
+ const merged = override ? { ...item, ...override } : item;
63
+ const filteredOut = !!visibleTags && !!merged.tags?.length && !merged.tags.some((tag) => visibleTags.includes(tag));
64
+ return { ...merged, id, hidden: !!merged.hidden || filteredOut };
65
+ });
66
+ }
67
+
68
+ /*
69
+ * Split the connections into the stretches between neighbouring items, skipping ids the board
70
+ * does not have. A stretch is hidden when its connection or either of its items is. Keys are
71
+ * unique even when two connections share a pair.
72
+ */
73
+ export function getVisionBoardSegments(
74
+ connections: VisionBoardConnection[],
75
+ itemsById: Map<string, ResolvedVisionBoardItem>,
76
+ defaultSlack: number,
77
+ ): VisionBoardSegment[] {
78
+ const segments: VisionBoardSegment[] = [];
79
+ const keys = new Set<string>();
80
+ for (const connection of connections) {
81
+ const slack = Math.max(0, connection.slack ?? defaultSlack);
82
+ for (let i = 0; i < connection.items.length - 1; i++) {
83
+ const from = itemsById.get(connection.items[i]);
84
+ const to = itemsById.get(connection.items[i + 1]);
85
+ if (!from || !to) continue;
86
+ let key = `${from.id}>${to.id}`;
87
+ for (let n = 2; keys.has(key); n++) key = `${from.id}>${to.id}#${n}`;
88
+ keys.add(key);
89
+ segments.push({
90
+ key,
91
+ from: from.id,
92
+ to: to.id,
93
+ slack,
94
+ color: connection.color ?? from.color,
95
+ width: connection.width,
96
+ dashed: !!connection.dashed,
97
+ hidden: !!connection.hidden || from.hidden || to.hidden,
98
+ });
99
+ }
100
+ }
101
+ return segments;
102
+ }
103
+
104
+ /**
105
+ * Geometry
106
+ */
107
+
108
+ /*
109
+ * Distance an item may sit from its home for a pointer `distance` away: free up to `limit`,
110
+ * then diminishing, never past `limit × (1 + stretch)`. Continuous in value and slope at the limit.
111
+ */
112
+ export function rubberBand(distance: number, limit: number, stretch: number) {
113
+ if (distance <= limit) return distance;
114
+ const room = limit * stretch;
115
+ return room > 0 ? limit + room * (1 - Math.exp(-(distance - limit) / room)) : limit;
116
+ }
117
+
118
+ /*
119
+ * Rest position of a string's bend between two points: the quadratic control point that makes
120
+ * the curve sag by `slack × length` straight down at its middle.
121
+ */
122
+ export function getStringRestControl(ax: number, ay: number, bx: number, by: number, slack: number): [number, number] {
123
+ const length = Math.hypot(bx - ax, by - ay);
124
+ return [(ax + bx) / 2, (ay + by) / 2 + 2 * slack * length];
125
+ }
126
+
127
+ /*
128
+ * SVG path of one string stretch through its control point, rounded to a tenth of a unit so a
129
+ * still string produces the same text each frame.
130
+ */
131
+ export function buildStringPath(ax: number, ay: number, cx: number, cy: number, bx: number, by: number) {
132
+ return `M${round(ax)} ${round(ay)}Q${round(cx)} ${round(cy)} ${round(bx)} ${round(by)}`;
133
+ }
134
+
135
+ /*
136
+ * Path of a string stretch at rest, for the markup before any physics has run.
137
+ */
138
+ export function buildRestStringPath(ax: number, ay: number, bx: number, by: number, slack: number) {
139
+ const [cx, cy] = getStringRestControl(ax, ay, bx, by, slack);
140
+ return buildStringPath(ax, ay, cx, cy, bx, by);
141
+ }
142
+
143
+ /*
144
+ * Where an item's text block sits relative to the node's center, in CSS pixels.
145
+ */
146
+ export function getVisionBoardTextStyle(
147
+ placement: VisionBoardTextPlacement,
148
+ nodeSize: number,
149
+ gap: number,
150
+ width: number,
151
+ ): CSSProperties {
152
+ const offset = nodeSize / 2 + gap;
153
+ switch (placement) {
154
+ case 'left':
155
+ return { right: offset, top: 0, width, transform: 'translateY(-50%)', textAlign: 'right' };
156
+ case 'top':
157
+ return { bottom: offset, left: 0, width, transform: 'translateX(-50%)', textAlign: 'center' };
158
+ case 'bottom':
159
+ return { top: offset, left: 0, width, transform: 'translateX(-50%)', textAlign: 'center' };
160
+ default:
161
+ return { left: offset, top: 0, width, transform: 'translateY(-50%)', textAlign: 'left' };
162
+ }
163
+ }
164
+
165
+ function round(value: number) {
166
+ return Math.round(value * 10) / 10;
167
+ }
168
+
169
+ /**
170
+ * Springs
171
+ */
172
+
173
+ interface SpringBody {
174
+ x: number;
175
+ y: number;
176
+ vx: number;
177
+ vy: number;
178
+ }
179
+
180
+ /*
181
+ * Advance a damped spring toward its target by `dt` seconds (semi-implicit Euler in sub-steps),
182
+ * mutating the body. Returns true once it has come to rest, having snapped it exactly onto the
183
+ * target so no residual keeps the frame loop alive.
184
+ */
185
+ export function stepSpring(body: SpringBody, targetX: number, targetY: number, dt: number, spring: VisionBoardSpring) {
186
+ const steps = Math.max(1, Math.ceil(dt / PHYSICS.subStep));
187
+ const h = dt / steps;
188
+ for (let i = 0; i < steps; i++) {
189
+ body.vx += (-spring.stiffness * (body.x - targetX) - spring.damping * body.vx) * h;
190
+ body.vy += (-spring.stiffness * (body.y - targetY) - spring.damping * body.vy) * h;
191
+ body.x += body.vx * h;
192
+ body.y += body.vy * h;
193
+ }
194
+ const settled =
195
+ Math.abs(body.x - targetX) < PHYSICS.settleDistance &&
196
+ Math.abs(body.y - targetY) < PHYSICS.settleDistance &&
197
+ Math.abs(body.vx) < PHYSICS.settleVelocity &&
198
+ Math.abs(body.vy) < PHYSICS.settleVelocity;
199
+ if (settled) {
200
+ body.x = targetX;
201
+ body.y = targetY;
202
+ body.vx = 0;
203
+ body.vy = 0;
204
+ }
205
+ return settled;
206
+ }
207
+
208
+ /**
209
+ * Engine
210
+ */
211
+
212
+ export interface VisionBoardEngineOptions {
213
+ dragLimit: number;
214
+ dragStretch: number;
215
+ throwFactor: number;
216
+ itemSpring: VisionBoardSpring;
217
+ /** `null` keeps the strings taut against their items. */
218
+ stringSpring: VisionBoardSpring | null;
219
+ }
220
+
221
+ interface EngineNode extends SpringBody {
222
+ el: HTMLElement | null;
223
+ /** Board position the element's `left` / `top` were rendered at; the transform is the offset from it. */
224
+ baseX: number;
225
+ baseY: number;
226
+ homeX: number;
227
+ homeY: number;
228
+ dragging: boolean;
229
+ settled: boolean;
230
+ /** The transform needs writing. */
231
+ dirty: boolean;
232
+ /** Time of the last drag move, for the velocity estimate. */
233
+ dragTime: number;
234
+ }
235
+
236
+ interface EngineSegment extends SpringBody {
237
+ from: string;
238
+ to: string;
239
+ slack: number;
240
+ /** The control point has been placed at least once. */
241
+ ready: boolean;
242
+ settled: boolean;
243
+ lastPath: string;
244
+ }
245
+
246
+ interface DragSession {
247
+ id: string;
248
+ left: number;
249
+ top: number;
250
+ /** Pointer offset from the item's center at grab, in board units, so the item does not jump under the pointer. */
251
+ grabX: number;
252
+ grabY: number;
253
+ }
254
+
255
+ export type VisionBoardEngine = ReturnType<typeof createVisionBoardEngine>;
256
+
257
+ /*
258
+ * Runs the board's motion outside React: items spring to their homes (and back from a drag),
259
+ * strings bend and settle behind them. Positions are in board units; the engine converts to
260
+ * CSS pixels with the current `scale` and writes each item's transform and each string's path
261
+ * straight to the DOM. One requestAnimationFrame loop runs only while something moves and
262
+ * stops on its own, so an idle board costs nothing. Safe to create during server rendering:
263
+ * nothing touches the document until an element is registered.
264
+ */
265
+ export function createVisionBoardEngine(initialOptions: VisionBoardEngineOptions) {
266
+ let options = initialOptions;
267
+ const nodes = new Map<string, EngineNode>();
268
+ const segments = new Map<string, EngineSegment>();
269
+ const segmentElements = new Map<string, SVGPathElement>();
270
+ let board: HTMLElement | null = null;
271
+ let scale = 0;
272
+ let rafId = 0;
273
+ let lastTime = 0;
274
+ let drag: DragSession | null = null;
275
+ let motionQuery: MediaQueryList | null = null;
276
+
277
+ /*
278
+ * Whether the visitor asked for reduced motion; then every body snaps instead of springing.
279
+ */
280
+ function reducedMotion() {
281
+ if (!motionQuery && typeof window !== 'undefined' && window.matchMedia) {
282
+ motionQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
283
+ }
284
+ return !!motionQuery?.matches;
285
+ }
286
+
287
+ /*
288
+ * Run the loop if it is not already scheduled.
289
+ */
290
+ function wake() {
291
+ if (!rafId && typeof requestAnimationFrame === 'function') rafId = requestAnimationFrame(frame);
292
+ }
293
+
294
+ function writeNode(node: EngineNode) {
295
+ if (!node.el) return;
296
+ const x = (node.x - node.baseX) * scale;
297
+ const y = (node.y - node.baseY) * scale;
298
+ node.el.style.transform = `translate3d(${x.toFixed(2)}px, ${y.toFixed(2)}px, 0)`;
299
+ node.dirty = false;
300
+ }
301
+
302
+ /*
303
+ * One frame: advance every body that is not at rest, write what changed, and reschedule
304
+ * only if something is still moving.
305
+ */
306
+ function frame(time: number) {
307
+ rafId = 0;
308
+ const dt = lastTime ? Math.min((time - lastTime) / 1000, PHYSICS.maxDt) : 0;
309
+ lastTime = time;
310
+ const snap = reducedMotion();
311
+ let active = false;
312
+
313
+ for (const node of nodes.values()) {
314
+ if (node.dragging) {
315
+ active = true;
316
+ } else if (!node.settled) {
317
+ if (snap) {
318
+ node.x = node.homeX;
319
+ node.y = node.homeY;
320
+ node.vx = 0;
321
+ node.vy = 0;
322
+ node.settled = true;
323
+ } else {
324
+ node.settled = stepSpring(node, node.homeX, node.homeY, dt, options.itemSpring);
325
+ }
326
+ node.dirty = true;
327
+ if (!node.settled) active = true;
328
+ }
329
+ if (node.dirty) writeNode(node);
330
+ }
331
+
332
+ for (const [key, segment] of segments) {
333
+ const el = segmentElements.get(key);
334
+ const a = nodes.get(segment.from);
335
+ const b = nodes.get(segment.to);
336
+ if (!el || !a || !b) continue;
337
+ const [restX, restY] = getStringRestControl(a.x, a.y, b.x, b.y, segment.slack);
338
+ const endsMoving = a.dragging || b.dragging || !a.settled || !b.settled;
339
+ if (!segment.ready) {
340
+ // The markup's rest path, so an unchanged string is not rewritten on the first frame.
341
+ segment.lastPath = el.getAttribute('d') ?? '';
342
+ }
343
+ if (!segment.ready || snap || !options.stringSpring) {
344
+ segment.x = restX;
345
+ segment.y = restY;
346
+ segment.vx = 0;
347
+ segment.vy = 0;
348
+ segment.ready = true;
349
+ segment.settled = true;
350
+ } else {
351
+ segment.settled = stepSpring(segment, restX, restY, dt, options.stringSpring);
352
+ }
353
+ const path = buildStringPath(a.x, a.y, segment.x, segment.y, b.x, b.y);
354
+ if (path !== segment.lastPath) {
355
+ segment.lastPath = path;
356
+ el.setAttribute('d', path);
357
+ }
358
+ if (!segment.settled || endsMoving) active = true;
359
+ }
360
+
361
+ if (active) rafId = requestAnimationFrame(frame);
362
+ else lastTime = 0;
363
+ }
364
+
365
+ /*
366
+ * Change the springs and drag limits; takes effect from the next frame.
367
+ */
368
+ function setOptions(next: VisionBoardEngineOptions) {
369
+ options = next;
370
+ wake();
371
+ }
372
+
373
+ /*
374
+ * The board element, for converting pointer positions during a drag.
375
+ */
376
+ function setBoard(el: HTMLElement | null) {
377
+ board = el;
378
+ }
379
+
380
+ /*
381
+ * CSS pixels per board unit; every item's transform is rewritten with the new scale.
382
+ */
383
+ function setScale(next: number) {
384
+ if (next === scale) return;
385
+ scale = next;
386
+ for (const node of nodes.values()) node.dirty = true;
387
+ wake();
388
+ }
389
+
390
+ /*
391
+ * Register an item's element, positioned in the markup at `baseX` / `baseY`; `null` forgets
392
+ * the item (and drops any drag on it).
393
+ */
394
+ function setNode(id: string, el: HTMLElement | null, baseX: number, baseY: number) {
395
+ if (!el) {
396
+ nodes.delete(id);
397
+ if (drag?.id === id) drag = null;
398
+ return;
399
+ }
400
+ const existing = nodes.get(id);
401
+ if (existing) {
402
+ existing.el = el;
403
+ existing.baseX = baseX;
404
+ existing.baseY = baseY;
405
+ existing.dirty = true;
406
+ } else {
407
+ nodes.set(id, {
408
+ el,
409
+ baseX,
410
+ baseY,
411
+ homeX: baseX,
412
+ homeY: baseY,
413
+ x: baseX,
414
+ y: baseY,
415
+ vx: 0,
416
+ vy: 0,
417
+ dragging: false,
418
+ settled: true,
419
+ dirty: false,
420
+ dragTime: 0,
421
+ });
422
+ }
423
+ wake();
424
+ }
425
+
426
+ /*
427
+ * Move an item's home; it springs there from wherever it is.
428
+ */
429
+ function setHome(id: string, x: number, y: number) {
430
+ const node = nodes.get(id);
431
+ if (!node || (node.homeX === x && node.homeY === y)) return;
432
+ node.homeX = x;
433
+ node.homeY = y;
434
+ node.settled = false;
435
+ wake();
436
+ }
437
+
438
+ /*
439
+ * Replace the set of string stretches, keeping the bend state of those that remain.
440
+ */
441
+ function setSegments(specs: VisionBoardSegment[]) {
442
+ const keep = new Set<string>();
443
+ for (const spec of specs) {
444
+ keep.add(spec.key);
445
+ const existing = segments.get(spec.key);
446
+ if (existing) {
447
+ existing.from = spec.from;
448
+ existing.to = spec.to;
449
+ if (existing.slack !== spec.slack) {
450
+ existing.slack = spec.slack;
451
+ existing.settled = false;
452
+ }
453
+ } else {
454
+ segments.set(spec.key, {
455
+ from: spec.from,
456
+ to: spec.to,
457
+ slack: spec.slack,
458
+ x: 0,
459
+ y: 0,
460
+ vx: 0,
461
+ vy: 0,
462
+ ready: false,
463
+ settled: false,
464
+ lastPath: '',
465
+ });
466
+ }
467
+ }
468
+ for (const key of segments.keys()) {
469
+ if (!keep.has(key)) segments.delete(key);
470
+ }
471
+ wake();
472
+ }
473
+
474
+ function setSegmentElement(key: string, el: SVGPathElement | null) {
475
+ if (el) segmentElements.set(key, el);
476
+ else segmentElements.delete(key);
477
+ }
478
+
479
+ /*
480
+ * Begin dragging an item from a pointer at `clientX` / `clientY`. Returns false when the
481
+ * board has not been measured yet or the item is unknown.
482
+ */
483
+ function startDrag(id: string, clientX: number, clientY: number) {
484
+ const node = nodes.get(id);
485
+ if (!node || !board || !scale) return false;
486
+ const rect = board.getBoundingClientRect();
487
+ drag = {
488
+ id,
489
+ left: rect.left,
490
+ top: rect.top,
491
+ grabX: (clientX - rect.left) / scale - node.x,
492
+ grabY: (clientY - rect.top) / scale - node.y,
493
+ };
494
+ node.dragging = true;
495
+ node.settled = false;
496
+ node.vx = 0;
497
+ node.vy = 0;
498
+ node.dragTime = 0;
499
+ if (node.el) node.el.style.zIndex = '1';
500
+ wake();
501
+ return true;
502
+ }
503
+
504
+ /*
505
+ * Follow the pointer, rubber-banding the item's distance from home, and keep a smoothed
506
+ * velocity so a release can throw it.
507
+ */
508
+ function moveDrag(id: string, clientX: number, clientY: number, time: number) {
509
+ const node = nodes.get(id);
510
+ if (!node || drag?.id !== id) return;
511
+ let dx = (clientX - drag.left) / scale - drag.grabX - node.homeX;
512
+ let dy = (clientY - drag.top) / scale - drag.grabY - node.homeY;
513
+ const distance = Math.hypot(dx, dy);
514
+ if (distance > 0) {
515
+ const banded = rubberBand(distance, options.dragLimit, options.dragStretch) / distance;
516
+ dx *= banded;
517
+ dy *= banded;
518
+ }
519
+ const x = node.homeX + dx;
520
+ const y = node.homeY + dy;
521
+ const dt = node.dragTime ? (time - node.dragTime) / 1000 : 0;
522
+ if (dt > 0) {
523
+ // A pause resets the estimate, otherwise blend in the latest sample.
524
+ const blend = dt * 1000 > PHYSICS.staleDragMs ? 1 : 0.5;
525
+ node.vx += ((x - node.x) / dt - node.vx) * blend;
526
+ node.vy += ((y - node.y) / dt - node.vy) * blend;
527
+ }
528
+ node.dragTime = time;
529
+ node.x = x;
530
+ node.y = y;
531
+ node.dirty = true;
532
+ wake();
533
+ }
534
+
535
+ /*
536
+ * Release the item: it keeps part of its velocity (none after a pause) and springs home.
537
+ */
538
+ function endDrag(id: string, time: number) {
539
+ const node = nodes.get(id);
540
+ if (!node || drag?.id !== id) return;
541
+ drag = null;
542
+ node.dragging = false;
543
+ node.settled = false;
544
+ const stale = !node.dragTime || time - node.dragTime > PHYSICS.staleDragMs;
545
+ node.vx = stale ? 0 : node.vx * options.throwFactor;
546
+ node.vy = stale ? 0 : node.vy * options.throwFactor;
547
+ if (node.el) node.el.style.zIndex = '';
548
+ wake();
549
+ }
550
+
551
+ /*
552
+ * Stop the frame loop; a later change wakes it again.
553
+ */
554
+ function dispose() {
555
+ if (rafId) cancelAnimationFrame(rafId);
556
+ rafId = 0;
557
+ lastTime = 0;
558
+ }
559
+
560
+ return { setOptions, setBoard, setScale, setNode, setHome, setSegments, setSegmentElement, startDrag, moveDrag, endDrag, dispose };
561
+ }