Skip to content

Commit abab26d

Browse files
committed
fix: clicking nodes no longer shifts the graph
Pin all existing nodes during dynamic neighbor injection so only new nodes move. Unpins after 600ms. Prevents the zoom-in effect caused by force simulation rearranging everything.
1 parent 64f8709 commit abab26d

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/lore/ui/src/graph/interaction.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,10 +212,26 @@ export class InteractionManager {
212212
}
213213
}
214214
if (addedAny) {
215+
// Pin all existing nodes so only new ones move
216+
for (const n of this.state.nodes) {
217+
if (!n._dynamic) {
218+
n.fx = n.x;
219+
n.fy = n.y;
220+
}
221+
}
215222
this.simulation.nodes(this.state.nodes);
216223
this.simulation.force('link').links(this.state.edges);
217-
this.simulation.alpha(0.3).restart();
224+
this.simulation.alpha(0.15).restart();
218225
this.rebuildQuadtree();
226+
// Unpin after settling
227+
setTimeout(() => {
228+
for (const n of this.state.nodes) {
229+
if (!n._dynamic) {
230+
n.fx = null;
231+
n.fy = null;
232+
}
233+
}
234+
}, 600);
219235
}
220236
this.state.setFocus(node.id, ids);
221237
});

0 commit comments

Comments
 (0)