jerosoler / Drawflow

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

add dblclick event in nodes #224

Closed PabloPerezAguilo closed 3 years ago

PabloPerezAguilo commented 3 years ago

May it be interesting to fire the dblclick event on a node? In this way we can add listeners on nodes to show contextual menu or whatever

DominicWindisch commented 3 years ago

There allready is an example for a node with a dblclick event here.

jerosoler commented 3 years ago

Other option for dblclick event:

          var id = document.getElementById("drawflow");
          const editor = new Drawflow(id);
          id.addEventListener('dblclick', (e) => {
            if(e.target.closest(".drawflow_content_node") != null || e.target.classList[0] === 'drawflow-node') {
                if(e.target.closest(".drawflow_content_node") != null) {
                    var input_id = e.target.closest(".drawflow_content_node").parentElement.id;
                } else {
                    var input_id = e.target.id;
                }
                alert(input_id.slice(5));
            }
          });

For contextmenu view: https://github.com/jerosoler/Drawflow/issues/187

PabloPerezAguilo commented 3 years ago

Great! Thx!