fix: Z-orddering with frames
Signed-off-by: Mark Tolmacs <mark@lazycat.hu>
This commit is contained in:
@@ -499,10 +499,7 @@ function shiftElementsAccountingForFrames(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
const frameAwareContiguousElementsToMove: {
|
const regularElements: ExcalidrawElement[] = [];
|
||||||
regularElements: ExcalidrawElement[];
|
|
||||||
frameChildren: Map<ExcalidrawFrameLikeElement["id"], ExcalidrawElement[]>;
|
|
||||||
} = { regularElements: [], frameChildren: new Map() };
|
|
||||||
|
|
||||||
const fullySelectedFrames = new Set<ExcalidrawFrameLikeElement["id"]>();
|
const fullySelectedFrames = new Set<ExcalidrawFrameLikeElement["id"]>();
|
||||||
|
|
||||||
@@ -518,46 +515,14 @@ function shiftElementsAccountingForFrames(
|
|||||||
isFrameLikeElement(element) ||
|
isFrameLikeElement(element) ||
|
||||||
(element.frameId && fullySelectedFrames.has(element.frameId))
|
(element.frameId && fullySelectedFrames.has(element.frameId))
|
||||||
) {
|
) {
|
||||||
frameAwareContiguousElementsToMove.regularElements.push(element);
|
regularElements.push(element);
|
||||||
} else if (!element.frameId) {
|
} else if (!element.frameId) {
|
||||||
frameAwareContiguousElementsToMove.regularElements.push(element);
|
regularElements.push(element);
|
||||||
} else {
|
|
||||||
const frameChildren =
|
|
||||||
frameAwareContiguousElementsToMove.frameChildren.get(
|
|
||||||
element.frameId,
|
|
||||||
) || [];
|
|
||||||
frameChildren.push(element);
|
|
||||||
frameAwareContiguousElementsToMove.frameChildren.set(
|
|
||||||
element.frameId,
|
|
||||||
frameChildren,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let nextElements = allElements;
|
return shiftFunction(allElements, appState, direction, null, regularElements);
|
||||||
|
|
||||||
const frameChildrenSets = Array.from(
|
|
||||||
frameAwareContiguousElementsToMove.frameChildren.entries(),
|
|
||||||
);
|
|
||||||
|
|
||||||
for (const [frameId, children] of frameChildrenSets) {
|
|
||||||
nextElements = shiftFunction(
|
|
||||||
allElements,
|
|
||||||
appState,
|
|
||||||
direction,
|
|
||||||
frameId,
|
|
||||||
children,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return shiftFunction(
|
|
||||||
nextElements,
|
|
||||||
appState,
|
|
||||||
direction,
|
|
||||||
null,
|
|
||||||
frameAwareContiguousElementsToMove.regularElements,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public API
|
// public API
|
||||||
|
|||||||
Reference in New Issue
Block a user