Do we have canvas Modified Event in Fabric.js?

后端 未结 2 519
一个人的身影
一个人的身影 2021-01-05 06:00

In Fabric.js we have Object modified events like object:modified. Do we have similar event for the entire canvas.

Actually I am trying to implement undo and redo fea

相关标签:
2条回答
  • 2021-01-05 06:29

    This is better explained in this link. Use it this way:

    canvas.on('object:moving', function(e) { // or 'object:added'
      var activeObject = e.target;
      console.log(activeObject.get('left'), activeObject.get('top'));
    });
    
    0 讨论(0)
  • 2021-01-05 06:44

    Don't forget to check for added/removed objects too. You could implement it like this:

    var canvasModifiedCallback = function() {
    console.log('canvas modified!');
    };
    
    canvas.on('object:added', canvasModifiedCallback);
    canvas.on('object:removed', canvasModifiedCallback);
    canvas.on('object:modified', canvasModifiedCallback);
    
    0 讨论(0)
提交回复
热议问题