Skip to content

Commit af25d00

Browse files
tidy(ui): use const for brush spacing
1 parent d4a30d0 commit af25d00

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

invokeai/frontend/web/src/features/regionalPrompts/hooks/mouseEventHooks.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const syncCursorPos = (stage: Konva.Stage): Vector2d | null => {
4444
return pos;
4545
};
4646

47+
const BRUSH_SPACING = 20;
48+
4749
export const useMouseEvents = () => {
4850
const dispatch = useAppDispatch();
4951
const selectedLayerId = useAppSelector((s) => s.regionalPrompts.present.selectedLayerId);
@@ -67,7 +69,6 @@ export const useMouseEvents = () => {
6769
if (!selectedLayerId) {
6870
return;
6971
}
70-
// const tool = getTool();
7172
if (tool === 'brush' || tool === 'eraser') {
7273
dispatch(
7374
maskLayerLineAdded({
@@ -121,7 +122,8 @@ export const useMouseEvents = () => {
121122
}
122123
if (getIsFocused(stage) && $isMouseOver.get() && $isMouseDown.get() && (tool === 'brush' || tool === 'eraser')) {
123124
if (lastCursorPosRef.current) {
124-
if (Math.hypot(lastCursorPosRef.current[0] - pos.x, lastCursorPosRef.current[1] - pos.y) < 20) {
125+
// Dispatching redux events impacts perf substantially - using brush spacing keeps dispatches to a reasonable number
126+
if (Math.hypot(lastCursorPosRef.current[0] - pos.x, lastCursorPosRef.current[1] - pos.y) < BRUSH_SPACING) {
125127
return;
126128
}
127129
}

0 commit comments

Comments
 (0)