@ruckc/truss-graph 1.5.0 → 1.6.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/dist/Graph.svelte +2 -1
- package/dist/routing.js +1 -1
- package/package.json +1 -1
package/dist/Graph.svelte
CHANGED
|
@@ -231,7 +231,8 @@
|
|
|
231
231
|
export function layout() {
|
|
232
232
|
nodes = computeLayout();
|
|
233
233
|
onchange?.();
|
|
234
|
-
|
|
234
|
+
// the graph may be gone by the next frame (navigating away right after pressing the button)
|
|
235
|
+
requestAnimationFrame(() => { if (root?.isConnected) fit(); });
|
|
235
236
|
}
|
|
236
237
|
function computeLayout(): GraphNode[] {
|
|
237
238
|
if (layoutMode === 'force') return forceLayout(nodes, edges);
|
package/dist/routing.js
CHANGED
|
@@ -16,7 +16,7 @@ export function defaultPorts(n, direction = 'LR') {
|
|
|
16
16
|
export function portAnchor(n, port, ports) {
|
|
17
17
|
const w = n.width ?? NODE_W, h = n.height ?? NODE_H;
|
|
18
18
|
const peers = ports.filter((p) => p.side === port.side);
|
|
19
|
-
const t = (peers.
|
|
19
|
+
const t = (peers.findIndex((p) => p.id === port.id) + 1) / (peers.length + 1); // by id: callers often derive `ports` anew (defaultPorts) so object identity is not stable
|
|
20
20
|
switch (port.side) {
|
|
21
21
|
case 'left': return { x: n.x, y: n.y + h * t, side: 'left' };
|
|
22
22
|
case 'right': return { x: n.x + w, y: n.y + h * t, side: 'right' };
|