This commit is contained in:
李志鹏
2026-01-20 10:31:47 +08:00
parent cdcb18c02c
commit eb1de5abb3
4 changed files with 23 additions and 20 deletions

View File

@@ -444,7 +444,7 @@ export class CanvasManager {
}
// 居中所有画布元素,包括背景层和其他元素
this.centerAllObjects();
await this.centerAllObjects();
// // 重新渲染画布使变更生效
// this.canvas.renderAll();
@@ -469,7 +469,6 @@ export class CanvasManager {
*/
async centerAllObjects() {
if (!this.canvas) return;
// 获取所有可见对象(不是背景元素的对象)
const allObjects = this.canvas.getObjects();
if (allObjects.length === 0) return;
@@ -484,9 +483,6 @@ export class CanvasManager {
// 获取背景对象
const backgroundObject = visibleObjects.find((obj) => obj.isBackground);
// !this.canvas?.clipPath &&
// this.centerBackgroundLayer(this.canvas.width, this.canvas.height);
this.canvas?.clipPath?.set?.({
left: this.width / 2,
top: this.height / 2,
@@ -578,6 +574,9 @@ export class CanvasManager {
});
});
}
!this.canvas?.clipPath &&
this.centerBackgroundLayer(this.canvas.width, this.canvas.height);
// 如果有背景层,更新蒙层位置
if (backgroundObject && CanvasConfig.isCropBackground) {