jerosoler / Drawflow

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

onClick and nodeSlected methods not working #637

Closed ringoCL closed 1 year ago

ringoCL commented 1 year ago

First of all, great work, thank you for your library. The methods clickEnd, click and nodeSlected are fired more like when touchstart event is executed, and not when the click is released or ended for example, wich makes imposible their use for launching a modal for example, because the modal is shown when the click is down and when the modal is closed the node that fired the event follows the mouse position until another click is executed. Iam using mackbook pro mouse pad and bluetooth mouse and the result is the same.

Is there a method to use properly to fire a modal when a node is clicked?

jerosoler commented 1 year ago

Hello thanks!

You cant detect in mouseup event.

    editor.on("mouseUp", (e) => {
      if(editor.node_selected !== null) {
        console.log(`Node selected: ${editor.node_selected.id}`);
      } else {
        console.log("Not node selected");
      } 
    })

Other solution:

ringoCL commented 1 year ago

Thank you!! mouseUp event did the trick.