Fabric.js - 居中后对象无法拖动/移动

dev*_*jim 2 javascript jquery fabricjs

我使用farbric.js在应用程序中编辑图像.图像应该能够调整大小,移动/拖动和旋转.问题是当我旋转图像时(通过单击按钮),它不会在画布的中心.所以我必须使用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();

}
Run Code Online (Sandbox Code Playgroud)

那么,问题是什么?还有其他任何修复方法吗?

Oni*_*rom 7

文件说:

您可能需要setCoords在居中后调用对象,以更新控件区域.

这样做this.Obj.setCoords();之后this.Obj.center();应该做的伎俩.