Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cancel event in fabric.js

I'd like to cancel the MouseEvent that is fired on object:moving in fabric.js, to prevent all the actions when some condition is met. I tried to set cancelBubble = true or simply return false; but with no success. Any ideas?

Sample fiddle with some event: http://jsfiddle.net/fabricjs/S9sLu/

like image 679
Bart Juriewicz Avatar asked Nov 26 '25 22:11

Bart Juriewicz


1 Answers

Mouse mouse:moving event is continuosly fired while mouse pointer is on canvas. But by checking event.target you can check if that's a generic or object related move.

canvas.on('mouse:move', function(options) { 
    if(options.target) {
    //suppress event handlers here
 }
});
like image 76
shershen Avatar answered Nov 29 '25 11:11

shershen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!