This commit is contained in:
李志鹏
2026-01-21 16:55:16 +08:00
parent 39a65add7c
commit 6b5c2c0b2e
3 changed files with 26 additions and 21 deletions

View File

@@ -71,17 +71,17 @@ export class LayerSort {
// if (!layer.visible) {
// continue;
// }
let id = layer.fabricObject?.id || layer.fabricObjects?.[0]?.id || null;
// 处理不同类型的图层
if (layer.isBackground && layer.fabricObject) {
if (layer.isBackground && id) {
// 背景图层对象放在最底层
zIndexMap.set(layer.fabricObject.id, currentZIndex++);
} else if (layer.isFixed && layer.fabricObject) {
zIndexMap.set(id, currentZIndex++);
} else if (layer.isFixed && id) {
// 固定图层对象
zIndexMap.set(layer.fabricObject.id, currentZIndex++);
} else if (layer.isFixedOther && layer.fabricObject) {
zIndexMap.set(id, currentZIndex++);
} else if (layer.isFixedOther && id) {
// 其他固定图层对象
zIndexMap.set(layer.fabricObject.id, currentZIndex++);
zIndexMap.set(id, currentZIndex++);
} else if (!layer.isBackground && !layer.isFixed) {
// 普通图层
currentZIndex = this.processLayerObjects(
@@ -91,7 +91,6 @@ export class LayerSort {
);
}
}
return zIndexMap;
}