错误
scaleX 不能从 0 开始,否则报错,错误如下:
fabric.js:4625 Uncaught InvalidStateError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The image argument is a canvas element with a width or height of 0.
提示: scaleY 可以是 0
正确代码
fabric.util.animate({
startValue: 0.01, // 不能是0,否则报错
endValue: 1,
duration: duration,
onChange: (value) => { // 过程函数
element.scaleX = value
canvasFab.renderAll();
},
onComplete: () => { // 结束函数
element.scaleX = 1
canvasFab.renderAll();
},
easing:easing
});