fabricjs / fabric.js

Javascript Canvas Library, SVG-to-Canvas (& canvas-to-SVG) Parser
http://fabricjs.com
Other
28.71k stars 3.49k forks source link

stopPropagation of events #5241

Closed durga598 closed 5 years ago

durga598 commented 5 years ago

Version

2.3.5

Test Case

http://jsfiddle.net/Da7SP/3024/

Steps to reproduce

Add more than one event listener with same event. Then stop propagation of events.

Expected Behavior

It should stop propagation of events.

Actual Behavior

Though there is no handler for that now, still it should stop the propagation.(feature)

asturur commented 5 years ago

Well those are syntetic events that fire on request. Is the observable pattern i guess. There is no way to stop them.

asturur commented 5 years ago

This could be achieved returning a defined value, false for example. But i m hesitant to insert a new logic in one of the few things that is not giving us problems. The order in which those functions are registered and executed is not under your direct control, so the concept of propagation does not apply completely.

durga598 commented 5 years ago

So we need to use a property to break the loop, which won't call the next event?

asturur commented 5 years ago

i think you should not try to organize your logic on breaking events. You can try to add a property to options and see if it goes to the next event, but that is not a public api feature, could be break in the future by other changes.