对象修改事件FabricJS(I-Text背景色)

时间:2018-06-11 18:09:40

标签: javascript jquery html web fabricjs

有没有办法告诉(立即)修改I-Text“textBackgroundColor”?

这是我的代码,但它只捕获移动事件或比例等,而不是I-Text'fill'或'textBackgroundColor'......

canvas.on('object:modified', function(e) {
   console.log('modification occurred')
   if (e.target.get('type') == 'i-text') {
       if (e.target.get('textBackgroundColor').length > 0) {
           console.log('background color exists');
       }
   }
}); 

1 个答案:

答案 0 :(得分:0)

不会因为财产变动而解雇object:modified。您可以使用canvas.fire('object:modified',{ target: object })手动触发事件,同时将属性设置为对象。