@floegence/floe-webapp-core 0.101.38 → 0.101.40

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.
@@ -0,0 +1,9 @@
1
+ import { type Setter } from 'solid-js';
2
+ import type { GraphViewport } from './types';
3
+ /** A controlled camera: direct input interrupts motion at the currently painted viewport. */
4
+ export declare function createGraphViewport(initial: GraphViewport): {
5
+ viewport: import("solid-js").Accessor<import("..").InfiniteCanvasPoint>;
6
+ setViewport: Setter<import("..").InfiniteCanvasPoint>;
7
+ animateTo: (next: GraphViewport) => void;
8
+ moving: import("solid-js").Accessor<boolean>;
9
+ };
@@ -0,0 +1,36 @@
1
+ import { createSignal as u, onMount as y, onCleanup as f, untrack as M } from "solid-js";
2
+ function F(p) {
3
+ const [s, r] = u(p), [w, i] = u(!1);
4
+ let a = 0, o;
5
+ const n = () => {
6
+ cancelAnimationFrame(a), a = 0, o = void 0, i(!1);
7
+ }, m = (e) => (n(), r(e)), h = (e) => {
8
+ n();
9
+ const t = M(s);
10
+ if (window.matchMedia("(prefers-reduced-motion: reduce)").matches || t.x === e.x && t.y === e.y && t.scale === e.scale) {
11
+ r(e);
12
+ return;
13
+ }
14
+ o = e;
15
+ const g = performance.now();
16
+ i(!0);
17
+ const l = (v) => {
18
+ const d = Math.min(1, (v - g) / 280), c = 1 - Math.pow(1 - d, 3);
19
+ r({
20
+ x: t.x + (e.x - t.x) * c,
21
+ y: t.y + (e.y - t.y) * c,
22
+ scale: t.scale + (e.scale - t.scale) * c
23
+ }), d < 1 ? a = requestAnimationFrame(l) : (r(e), n());
24
+ };
25
+ a = requestAnimationFrame(l);
26
+ };
27
+ return y(() => {
28
+ const e = window.matchMedia("(prefers-reduced-motion: reduce)"), t = () => {
29
+ e.matches && o && m(o);
30
+ };
31
+ e.addEventListener("change", t), f(() => e.removeEventListener("change", t));
32
+ }), f(n), { viewport: s, setViewport: m, animateTo: h, moving: w };
33
+ }
34
+ export {
35
+ F as createGraphViewport
36
+ };
package/dist/graph.d.ts CHANGED
@@ -3,3 +3,4 @@ export * from './components/graph/geometry';
3
3
  export * from './components/graph/engine';
4
4
  export * from './components/graph/GraphCanvas';
5
5
  export * from './components/graph/GraphMinimap';
6
+ export * from './components/graph/viewport-motion';
package/dist/graph.js CHANGED
@@ -1,12 +1,14 @@
1
- import { fitGraphViewport as e, graphEdgeLabelPosition as o, graphRelatedEdges as p, graphSectionPath as t } from "./components/graph/geometry.js";
1
+ import { fitGraphViewport as a, graphEdgeLabelPosition as o, graphRelatedEdges as p, graphSectionPath as t } from "./components/graph/geometry.js";
2
2
  import { createGraphLayoutEngine as i } from "./components/graph/engine.js";
3
- import { GraphCanvas as n } from "./components/graph/GraphCanvas.js";
4
- import { GraphMinimap as m } from "./components/graph/GraphMinimap.js";
3
+ import { GraphCanvas as g } from "./components/graph/GraphCanvas.js";
4
+ import { GraphMinimap as n } from "./components/graph/GraphMinimap.js";
5
+ import { createGraphViewport as G } from "./components/graph/viewport-motion.js";
5
6
  export {
6
- n as GraphCanvas,
7
- m as GraphMinimap,
7
+ g as GraphCanvas,
8
+ n as GraphMinimap,
8
9
  i as createGraphLayoutEngine,
9
- e as fitGraphViewport,
10
+ G as createGraphViewport,
11
+ a as fitGraphViewport,
10
12
  o as graphEdgeLabelPosition,
11
13
  p as graphRelatedEdges,
12
14
  t as graphSectionPath
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@floegence/floe-webapp-core",
3
- "version": "0.101.38",
3
+ "version": "0.101.40",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",