jerosoler / Drawflow

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

nodeMoved event is not being emitted #309

Closed JDanP closed 2 years ago

JDanP commented 2 years ago

Hi!

I am using the event nodeMoved to execute some code. The problem is that the event is not being emitted in a particular unfortunate situation: While moving a node (left click button pressed), move the cursor out of the editor, release the left click button, comes back to editor to drop the node and click to drop it: the event is not emitted. It seems nothing, but sadly I have very important code that relies on this event and in my app it is very easy to get to this issue. Do you have any idea how to solve it or to force to emit this event somehow?

Evidence with console.log() in https://jerosoler.github.io/Drawflow/:

Feature: image

Issue: image

Thanks in advance!

jerosoler commented 2 years ago

Hi @JDanP

You can solve the problem with:

editor.on('click', (e) => {
      if(editor.drag) {
        editor.dispatch('nodeMoved', editor.ele_selected.id.slice(5));
      }
})

Jero

JDanP commented 2 years ago

It worked perfectly! Thanks a lot!