fix
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -697,6 +697,7 @@ export class LayerManager {
|
||||
* 初始化图层,确保有背景层、固定图层和一个空白图层
|
||||
*/
|
||||
async initializeLayers() {
|
||||
console.log("初始化图层",this.layers.value.length)
|
||||
// 如果没有任何图层,创建背景层、固定图层和一个空白图层
|
||||
if (this.layers.value.length === 0) {
|
||||
// 创建背景图层
|
||||
|
||||
Reference in New Issue
Block a user