diff --git a/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx b/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx index c66c15d61b..d0d693a5f2 100644 --- a/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx +++ b/invokeai/frontend/web/src/features/controlLayers/components/StageComponent.tsx @@ -6,7 +6,7 @@ import { createMemoizedSelector } from 'app/store/createMemoizedSelector'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { useMouseEvents } from 'features/controlLayers/hooks/mouseEventHooks'; import { - $cursorPosition, + $lastCursorPos, $lastMouseDownPos, $tool, isRegionalGuidanceLayer, @@ -48,7 +48,7 @@ const useStageRenderer = ( const state = useAppSelector((s) => s.controlLayers.present); const tool = useStore($tool); const mouseEventHandlers = useMouseEvents(); - const cursorPosition = useStore($cursorPosition); + const lastCursorPos = useStore($lastCursorPos); const lastMouseDownPos = useStore($lastMouseDownPos); const selectedLayerIdColor = useAppSelector(selectSelectedLayerColor); const selectedLayerType = useAppSelector(selectSelectedLayerType); @@ -141,7 +141,7 @@ const useStageRenderer = ( selectedLayerIdColor, selectedLayerType, state.globalMaskLayerOpacity, - cursorPosition, + lastCursorPos, lastMouseDownPos, state.brushSize ); @@ -152,7 +152,7 @@ const useStageRenderer = ( selectedLayerIdColor, selectedLayerType, state.globalMaskLayerOpacity, - cursorPosition, + lastCursorPos, lastMouseDownPos, state.brushSize, renderers, diff --git a/invokeai/frontend/web/src/features/controlLayers/hooks/mouseEventHooks.ts b/invokeai/frontend/web/src/features/controlLayers/hooks/mouseEventHooks.ts index 03595fb82d..b9716ba217 100644 --- a/invokeai/frontend/web/src/features/controlLayers/hooks/mouseEventHooks.ts +++ b/invokeai/frontend/web/src/features/controlLayers/hooks/mouseEventHooks.ts @@ -3,8 +3,8 @@ import { useStore } from '@nanostores/react'; import { useAppDispatch, useAppSelector } from 'app/store/storeHooks'; import { calculateNewBrushSize } from 'features/canvas/hooks/useCanvasZoom'; import { - $cursorPosition, $isDrawing, + $lastCursorPos, $lastMouseDownPos, $tool, brushSizeChanged, @@ -63,7 +63,7 @@ const syncCursorPos = (stage: Konva.Stage): Vector2d | null => { if (!pos) { return null; } - $cursorPosition.set(pos); + $lastCursorPos.set(pos); return pos; }; @@ -117,7 +117,7 @@ export const useMouseEvents = () => { if (!stage) { return; } - const pos = $cursorPosition.get(); + const pos = $lastCursorPos.get(); if (!pos || !selectedLayerId || selectedLayerType !== 'regional_guidance_layer') { return; } @@ -188,7 +188,7 @@ export const useMouseEvents = () => { dispatch(rgLayerPointsAdded({ layerId: selectedLayerId, point: [pos.x, pos.y] })); } $isDrawing.set(false); - $cursorPosition.set(null); + $lastCursorPos.set(null); $lastMouseDownPos.set(null); }, [selectedLayerId, selectedLayerType, tool, dispatch] diff --git a/invokeai/frontend/web/src/features/controlLayers/store/controlLayersSlice.ts b/invokeai/frontend/web/src/features/controlLayers/store/controlLayersSlice.ts index f6a6f0b38d..fc1887f425 100644 --- a/invokeai/frontend/web/src/features/controlLayers/store/controlLayersSlice.ts +++ b/invokeai/frontend/web/src/features/controlLayers/store/controlLayersSlice.ts @@ -866,7 +866,7 @@ const migrateControlLayersState = (state: any): any => { export const $isDrawing = atom(false); export const $lastMouseDownPos = atom(null); export const $tool = atom('brush'); -export const $cursorPosition = atom(null); +export const $lastCursorPos = atom(null); // IDs for singleton Konva layers and objects export const TOOL_PREVIEW_LAYER_ID = 'tool_preview_layer';