Fixes reset canvas view when locked

This commit is contained in:
psychedelicious 2022-11-17 19:46:01 +11:00 committed by blessedcoolant
parent 425d3bc95d
commit ed70fc683c

View File

@ -439,14 +439,21 @@ export const canvasSlice = createSlice({
const { contentRect } = action.payload;
const baseCanvasImage = state.layerState.objects.find(isCanvasBaseImage);
const { shouldLockToInitialImage } = state;
const { shouldLockToInitialImage, initialCanvasImageClipRect } = state;
if (!baseCanvasImage) return;
const {
stageDimensions: { width: stageWidth, height: stageHeight },
} = state;
const { x, y, width, height } = contentRect;
let { x, y, width, height } = contentRect;
if (shouldLockToInitialImage && initialCanvasImageClipRect) {
x = initialCanvasImageClipRect.clipX;
y = initialCanvasImageClipRect.clipY;
width = initialCanvasImageClipRect.clipWidth;
height = initialCanvasImageClipRect.clipHeight;
}
const padding = shouldLockToInitialImage ? 1 : 0.95;
const newScale = calculateScale(