mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
perf: use UIAppState
where possible to reduce UI rerenders (#6560)
This commit is contained in:
parent
026949204d
commit
560231d365
33 changed files with 155 additions and 125 deletions
|
@ -30,7 +30,7 @@ export const getElementsWithinSelection = (
|
|||
|
||||
export const isSomeElementSelected = (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: Pick<AppState, "selectedElementIds">,
|
||||
): boolean =>
|
||||
elements.some((element) => appState.selectedElementIds[element.id]);
|
||||
|
||||
|
@ -40,7 +40,7 @@ export const isSomeElementSelected = (
|
|||
*/
|
||||
export const getCommonAttributeOfSelectedElements = <T>(
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: Pick<AppState, "selectedElementIds">,
|
||||
getAttribute: (element: ExcalidrawElement) => T,
|
||||
): T | null => {
|
||||
const attributes = Array.from(
|
||||
|
@ -55,7 +55,7 @@ export const getCommonAttributeOfSelectedElements = <T>(
|
|||
|
||||
export const getSelectedElements = (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: Pick<AppState, "selectedElementIds">,
|
||||
includeBoundTextElement: boolean = false,
|
||||
) =>
|
||||
elements.filter((element) => {
|
||||
|
@ -74,7 +74,7 @@ export const getSelectedElements = (
|
|||
|
||||
export const getTargetElements = (
|
||||
elements: readonly NonDeletedExcalidrawElement[],
|
||||
appState: AppState,
|
||||
appState: Pick<AppState, "selectedElementIds" | "editingElement">,
|
||||
) =>
|
||||
appState.editingElement
|
||||
? [appState.editingElement]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue