react-diagrams
react-diagrams copied to clipboard
Update links after re-positioning node
Hi,
I'm trying to do something similar to this https://github.com/projectstorm/react-diagrams/issues/107
However the answer is 4 years old and doesn't appear to be valid anymore.
I'm moving nodes via a websocket update,
node.getPosition().x = position.x
node.getPosition().y = position.y
I'm trying to update the links after moving the node.
I've tried removing them
Object.values(node.getPorts()).map((port:PortModel) =>
Object.values(port.getLinks()).map((link:LinkModel) =>
this.diagramModel.removeLink(link)))
And then re-adding them but they're still going to the old port positions when I repaint.
How can I get the engine to re-draw the links?
Maybe this helps?
import { PathFindingLinkFactory } from '@projectstorm/react-diagrams';
const reroute = (engine) => {
engine
.getLinkFactories()
.getFactory(PathFindingLinkFactory.NAME)
.calculateRoutingMatrix();
};