Resets bounding box coords/dims when no image present

This commit is contained in:
psychedelicious 2022-11-18 17:23:04 +11:00 committed by blessedcoolant
parent bb70c32ad5
commit 84f702b6d0
2 changed files with 12 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import { createSelector } from '@reduxjs/toolkit';
import {
resetCanvas,
resetCanvasView,
resizeAndScaleCanvas,
setTool,
} from 'features/canvas/store/canvasSlice';
import { useAppDispatch, useAppSelector } from 'app/store';
@ -131,7 +132,7 @@ const IAICanvasOutpaintingControls = () => {
const handleSelectMoveTool = () => dispatch(setTool('move'));
const handleResetCanvasView = () => {
const canvasBaseLayer = getCanvasBaseLayer()
const canvasBaseLayer = getCanvasBaseLayer();
if (!canvasBaseLayer) return;
const clientRect = canvasBaseLayer.getClientRect({
skipTransform: true,
@ -143,7 +144,10 @@ const IAICanvasOutpaintingControls = () => {
);
};
const handleResetCanvas = () => dispatch(resetCanvas());
const handleResetCanvas = () => {
dispatch(resetCanvas());
dispatch(resizeAndScaleCanvas());
};
const handleMergeVisible = () => {
dispatch(mergeAndUploadCanvas({}));

View File

@ -394,8 +394,9 @@ export const canvasSlice = createSlice({
);
state.stageScale = newScale;
state.stageCoordinates = newCoordinates;
state.boundingBoxCoordinates = { x: 0, y: 0 };
state.boundingBoxDimensions = { width: 512, height: 512 };
return;
}
@ -461,6 +462,8 @@ export const canvasSlice = createSlice({
state.stageScale = newScale;
state.stageCoordinates = newCoordinates;
state.boundingBoxCoordinates = { x: 0, y: 0 };
state.boundingBoxDimensions = { width: 512, height: 512 };
}
},
resetCanvasView: (
@ -496,7 +499,6 @@ export const canvasSlice = createSlice({
);
state.stageScale = newScale;
state.stageCoordinates = newCoordinates;
} else {
const newScale = calculateScale(
@ -518,8 +520,9 @@ export const canvasSlice = createSlice({
);
state.stageScale = newScale;
state.stageCoordinates = newCoordinates;
state.boundingBoxCoordinates = { x: 0, y: 0 };
state.boundingBoxDimensions = { width: 512, height: 512 };
}
},
nextStagingAreaImage: (state) => {