fix(ui): reset canvas coords/dims on reset

This commit is contained in:
psychedelicious 2024-01-09 18:49:50 +11:00 committed by Kent Keirsey
parent ebd68b7a6c
commit 9e1dd8ac9c

View File

@ -462,10 +462,31 @@ export const canvasSlice = createSlice({
}, },
resetCanvas: (state) => { resetCanvas: (state) => {
state.pastLayerStates.push(cloneDeep(state.layerState)); state.pastLayerStates.push(cloneDeep(state.layerState));
state.layerState = cloneDeep(initialLayerState); state.layerState = cloneDeep(initialLayerState);
state.futureLayerStates = []; state.futureLayerStates = [];
state.batchIds = []; state.batchIds = [];
state.boundingBoxCoordinates = {
...initialCanvasState.boundingBoxCoordinates,
};
state.boundingBoxDimensions = {
...initialCanvasState.boundingBoxDimensions,
};
state.stageScale = calculateScale(
state.stageDimensions.width,
state.stageDimensions.height,
state.boundingBoxDimensions.width,
state.boundingBoxDimensions.height,
STAGE_PADDING_PERCENTAGE
);
state.stageCoordinates = calculateCoordinates(
state.stageDimensions.width,
state.stageDimensions.height,
0,
0,
state.boundingBoxDimensions.width,
state.boundingBoxDimensions.height,
1
);
}, },
canvasResized: ( canvasResized: (
state, state,