perf(ui): do not use stage.find

This commit is contained in:
psychedelicious 2024-07-05 00:43:55 +10:00
parent 03ea005e9c
commit 41c195d936

View File

@ -8,7 +8,7 @@ import { clamp } from 'lodash-es';
import { v4 as uuidv4 } from 'uuid';
import { BRUSH_SPACING_TARGET_SCALE, CANVAS_SCALE_BY, MAX_CANVAS_SCALE, MIN_CANVAS_SCALE } from './constants';
import { getBrushLineId, PREVIEW_TOOL_GROUP_ID } from './naming';
import { getBrushLineId } from './naming';
/**
* Updates the last cursor position atom with the current cursor position, returning the new position or `null` if the
@ -363,10 +363,6 @@ export const setStageEventHandlers = (manager: CanvasManager): (() => void) => {
const selectedEntity = getSelectedEntity();
const selectedEntityAdapter = getSelectedEntityAdapter();
stage
.findOne<Konva.Layer>(`#${PREVIEW_TOOL_GROUP_ID}`)
?.visible(toolState.selected === 'brush' || toolState.selected === 'eraser');
if (
pos &&
selectedEntity &&
@ -500,8 +496,6 @@ export const setStageEventHandlers = (manager: CanvasManager): (() => void) => {
const selectedEntity = getSelectedEntity();
const toolState = getToolState();
stage.findOne<Konva.Layer>(`#${PREVIEW_TOOL_GROUP_ID}`)?.visible(false);
if (pos && selectedEntity && isDrawableEntity(selectedEntity) && !getSpaceKey() && getIsMouseDown()) {
if (getIsMouseDown()) {
if (toolState.selected === 'brush') {