I would like to resize a fabricjs rect instead of scale it, but I'm seeing weird behaviour while dragging the resize handles. The border starts to disappear or duplicate. I've tried both the stable version 1.7.19 and the beta 2.0.0 of fabricjs.
Here is the essence of the code I'm using:
canvas.on('object:scaling', function(){
var obj = canvas.getActiveObject(),
width = obj.width,
height = obj.height,
scaleX = obj.scaleX,
scaleY = obj.scaleY;
obj.set({
width : width * scaleX,
height : height * scaleY,
scaleX: 1,
scaleY: 1
});
});
Working example here: https://codepen.io/bramchi/pen/GMLYEV/
Try scaling it up and down a bit by dragging the resize handles.
Screenshot of scaling up and down issues
What I would expect to happen is the rectangle growing and shrinking while dragging the handles, and the border size to stay the same. But somehow rendering starts to go bonkers if you cross 270px or so. When the mouse button is released, it renders properly again.
What am I doing wrong? Who knows a fix? Or could this be a bug in the library I can report?