jerosoler / Drawflow

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

double clicked node #531

Closed quentingosset closed 2 years ago

quentingosset commented 2 years ago

Hello, I see in your example, that it is possible to make a node that has a method ondbclick() in the HTML to execute a modal. However, I would like to know if there is a trigger directly by the editor for a double click on a node.

I know that there is for a selected node:

editor.on('nodeSelected', function (id) {
        toggleSidebar("right");
    });

however I would like to trigger a double click on the node. Is there a way to do this without having to use the method in the HTML?

Aravinda93 commented 2 years ago

Its possible to do, here is a link to the same: https://github.com/jerosoler/Drawflow/issues/299#issuecomment-968281180

The above example is for connector but I guess you can do the same for node.

quentingosset commented 2 years ago

I used the doubleclick rewrite because the clickEnd doesn't fit my needs as I need an event on a doubleclick but is there a way to get the ID of the clicker node or do I have to use the read data-id technique in the event.target ?

editor.dblclick = function(e) {
      if(this.node_selected != null){ 
      console.log(HERE MY NODE ID);
      }
      if(this.connection_selected != null && this.reroute) {
        this.createReroutePoint(this.connection_selected);
      }
      if(e.target.classList[0] === 'point') {
          this.removeReroutePoint(e.target);
      }
      if (e.detail === 2 && e.target.classList[0] === "main-path") {
        console.log(editor.connection_selected);
      }

    } 

ok find with this code : this.node_selected.id.slice(5)