perf: improve element in frame check (#7124)

This commit is contained in:
Ryan Di 2023-10-09 16:32:27 +08:00 committed by GitHub
parent 03da9112cf
commit f20ba90ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -707,6 +707,17 @@ export const isElementInFrame = (
: element; : element;
if (frame) { if (frame) {
// Perf improvement:
// For an element that's already in a frame, if it's not being dragged
// then there is no need to refer to geometry (which, yes, is slow) to check if it's in a frame.
// It has to be in its containing frame.
if (
!appState.selectedElementIds[element.id] ||
!appState.selectedElementsAreBeingDragged
) {
return true;
}
if (_element.groupIds.length === 0) { if (_element.groupIds.length === 0) {
return elementOverlapsWithFrame(_element, frame); return elementOverlapsWithFrame(_element, frame);
} }