From f20ba90ffa2b3cf6c38844dd4bc6c8d816927f3b Mon Sep 17 00:00:00 2001 From: Ryan Di Date: Mon, 9 Oct 2023 16:32:27 +0800 Subject: [PATCH] perf: improve element in frame check (#7124) --- src/frame.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/frame.ts b/src/frame.ts index 9ec98b9e..1da9cfa1 100644 --- a/src/frame.ts +++ b/src/frame.ts @@ -707,6 +707,17 @@ export const isElementInFrame = ( : element; 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) { return elementOverlapsWithFrame(_element, frame); }