jerosoler / Drawflow

Simple flow library 🖥️🖱️
https://jerosoler.github.io/Drawflow/
MIT License
4.78k stars 741 forks source link

create connection with Node(double-click) ? #466

Closed urveerendra closed 2 years ago

urveerendra commented 2 years ago

Hi @jerosoler, I have 2 queries,

  1. Can we connect the node created(double-clicked) on the connection, to any input of other Nodes(dragged) ?

In the below example "node-A" is created by double-click, from the point I need to connect to "Send Email" and "Save log file" as well. is there any way to do it?

image

  1. Right now we can connect outputs to inputs of nodes. Can we also connect from input to outputs of nodes?
jerosoler commented 2 years ago

Hello,

I'm not sure what you're asking for. 1: But you can create a connection via javascript with the addConnection(id_output, id_input, output_class, input_class) method.

It could listen to the "clickEnd" and "mouseUp" events and create its connection.

3: Connections from the inputs are not considered.

urveerendra commented 2 years ago

Thanks for confirming on point 3.

On Point 1: I was asking, just like we have input and output for every node and then we create connection by dragging its output, Can we add input and output to a node which is created on double click of a connection(like "A" in the picture), so that I can connect its output to other nodes(send email, save log file, etc)

In other words, Can i split an existing connection and connect it to other nodes.

jerosoler commented 2 years ago

It could be created with the events described above. But it is complicated. Since each connection is independent. A connection cannot have child connections.

Besides, when you click on point A, the connection moves, it does not create another one, in that case, how should it behave?

There are many variables to take into account.

urveerendra commented 2 years ago

"Besides, when you click on point A, the connection moves, it does not create another one, in that case, how should it behave?" Ans: It can move, but only thing is it should accept the incoming connections.

Point here is, my Node - A should act as the spliter which supply 2 or 3 connections to respective other nodes.

urveerendra commented 2 years ago

Need help in understanding, by any chance, can we get an event when "circle" added into drawflow-canvas on the double click of the connection? or can we get any connection events, when node(double-clicked) gets created or connected?

jerosoler commented 2 years ago

Event exists: addReroute

urveerendra commented 2 years ago

I was able to make the change. Thanks for making it so easy to understand! Thank you. Happy coding.