jerosoler / Drawflow

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

[FEAT] ConnectionStart and ConnectionCancel events #113

Closed BobBDE closed 3 years ago

BobBDE commented 3 years ago

Hello,

I'm back with a new request, tell me what you think of it :)

It will be nice to have an event when the user start creating a new connection and another event when the user canceled the connection.

I think adding thses kind of event is a good idea because it makes the library more open to modificiation and more adaptable for different cases.

For me it will be useful to highlight the input/output that are compatible with the node where the connection started.

Do you think it is possible to add those events ?

Have a nice day :)

jerosoler commented 3 years ago

Hello @BobBDE

How would you indicate the compatible inputs / outputs? What I thought of your day: https://github.com/jerosoler/Drawflow/issues/45#issuecomment-701554099 Although it is a bit complicated to implement.

Another option that may be better would be to cancel the creation of the connection. View: https://github.com/jerosoler/Drawflow/issues/35 and https://github.com/jerosoler/Drawflow/issues/10#issuecomment-658274839

Jero

BobBDE commented 3 years ago

I would like to event like ConnectionStart (triggered when starting a new connection with the input or output information) and a ConnectionCancel (triggered when the new connectoin is canceled with the input or output information).

If those events exist, the developer could add fonctionalities to his drawflow. For example for me I would be able to highlight the compatible input or output (because added a type to the input and outputs).

The hightlight is a specific need for me but those events could help other developper to develop new functionalities with drawflow.

What do you think ?

jerosoler commented 3 years ago

Hello

Added new events on version 0.0.35

Event Return Description
connectionStart { output_id, output_class } id of nodes and ouput selected
connectionCancel true Connection Cancel
editor.on("connectionStart", function(e) {
      console.log("connectionStart");
      console.log(e);
})
editor.on("connectionCancel", function(e) {
      console.log("connectionCancel");
      console.log(e);
})

Jero

BobBDE commented 3 years ago

Hello Jero,

Waow, thank you for your reactivity. I hope this will help other developper :)

I will test it soon.

Thank you !