File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
invokeai/frontend/web/src/features/regionalPrompts/hooks Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ const syncCursorPos = (stage: Konva.Stage): Vector2d | null => {
44
44
return pos ;
45
45
} ;
46
46
47
+ const BRUSH_SPACING = 20 ;
48
+
47
49
export const useMouseEvents = ( ) => {
48
50
const dispatch = useAppDispatch ( ) ;
49
51
const selectedLayerId = useAppSelector ( ( s ) => s . regionalPrompts . present . selectedLayerId ) ;
@@ -67,7 +69,6 @@ export const useMouseEvents = () => {
67
69
if ( ! selectedLayerId ) {
68
70
return ;
69
71
}
70
- // const tool = getTool();
71
72
if ( tool === 'brush' || tool === 'eraser' ) {
72
73
dispatch (
73
74
maskLayerLineAdded ( {
@@ -121,7 +122,8 @@ export const useMouseEvents = () => {
121
122
}
122
123
if ( getIsFocused ( stage ) && $isMouseOver . get ( ) && $isMouseDown . get ( ) && ( tool === 'brush' || tool === 'eraser' ) ) {
123
124
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 ) {
125
127
return ;
126
128
}
127
129
}
You can’t perform that action at this time.
0 commit comments