我正在使用 farbric.js 在应用程序中编辑图像。 图像应该能够调整大小、移动/拖动和旋转。 问题是当我旋转图像(通过单击按钮)时,它不会位于 Canvas 的中心。所以我必须使用 centerObject() 才能使其正常工作。 但是,完成此操作后,图像无法再拖动。
这是处理旋转的函数(它在一个类中):
rotationset : function(angle, offsetX, offsetY){
// this.obj is the origin object
this.Obj.left = offsetX;
this.Obj.top = offsetY;
this.Obj.angle = angle;
this.Obj.center();//center the image
//this.canvas also initialized on load.
this.canvas.calcOffset();
this.canvas.renderAll();
}
那么,问题出在哪里呢?还有其他解决办法吗?
最佳答案
文档说:
You might need to call
setCoords
on an object after centering, to update controls area.
在 this.Obj.center();
之后执行 this.Obj.setCoords();
应该可以解决问题。
关于javascript - Fabric.js - 对象居中后无法拖动/移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29647944/