@@ -38,15 +38,6 @@ export const getScaledFlooredCursorPosition = (stage: Konva.Stage) => {
3838 } ;
3939} ;
4040
41- const syncCursorPos = ( stage : Konva . Stage ) => {
42- const pos = getScaledFlooredCursorPosition ( stage ) ;
43- if ( ! pos ) {
44- return null ;
45- }
46- $cursorPosition . set ( pos ) ;
47- return pos ;
48- } ;
49-
5041export const useMouseEvents = ( ) => {
5142 const dispatch = useAppDispatch ( ) ;
5243 const selectedLayerId = useAppSelector ( ( s ) => s . regionalPrompts . present . selectedLayerId ) ;
@@ -61,7 +52,7 @@ export const useMouseEvents = () => {
6152 if ( ! stage ) {
6253 return ;
6354 }
64- const pos = syncCursorPos ( stage ) ;
55+ const pos = $cursorPosition . get ( ) ;
6556 if ( ! pos ) {
6657 return ;
6758 }
@@ -118,13 +109,14 @@ export const useMouseEvents = () => {
118109 if ( ! stage ) {
119110 return ;
120111 }
121- const pos = syncCursorPos ( stage ) ;
112+ const pos = getScaledFlooredCursorPosition ( stage ) ;
122113 if ( ! pos || ! selectedLayerId ) {
123114 return ;
124115 }
116+ $cursorPosition . set ( pos ) ;
125117 if ( getIsFocused ( stage ) && $isMouseOver . get ( ) && $isMouseDown . get ( ) && ( tool === 'brush' || tool === 'eraser' ) ) {
126118 if ( lastCursorPosRef . current ) {
127- if ( Math . hypot ( lastCursorPosRef . current [ 0 ] - pos . x , lastCursorPosRef . current [ 1 ] - pos . y ) < 10 ) {
119+ if ( Math . hypot ( lastCursorPosRef . current [ 0 ] - pos . x , lastCursorPosRef . current [ 1 ] - pos . y ) < 20 ) {
128120 return ;
129121 }
130122 }
@@ -152,7 +144,7 @@ export const useMouseEvents = () => {
152144 return ;
153145 }
154146 $isMouseOver . set ( true ) ;
155- const pos = syncCursorPos ( stage ) ;
147+ const pos = $cursorPosition . get ( ) ;
156148 if ( ! pos ) {
157149 return ;
158150 }
0 commit comments