Closed manhvd161 closed 3 years ago
This is doable. You will have to implement a custom DragNewLinkState
and change the fire
callback function on the MOUSE_UP
action.
You could change it to something like this:
fire: (event) => {
const model = this.engine.getMouseElement(event.event);
if (!(model instanceof NodeModel)) return;
const targetPort = Object.values(model.getPorts())[0]; // just grabbing the first port of the node
if (this.port.canLinkToPort(targetPort)) {
this.link.setTargetPort(targetPort);
targetPort.reportPosition();
this.engine.repaintCanvas();
}
}
@renato-bohler thanks for helping @Sieusaosieungo
I have 2 nodes with big size. I want to connect them but I can only connect them by connecting from one port to another, I just want to connect from port of one node and hover on the other node will automatically find the port for me. This mechanism is similar to astah.