fix(ui): fix canvas staging images offset from bounding box

The staging area used the stage bbox, not the staging area bbox.
This commit is contained in:
psychedelicious 2023-09-27 17:07:37 +10:00
parent 8b969053e7
commit 53eb23b8b6

View File

@ -3,10 +3,9 @@ import { useAppSelector } from 'app/store/storeHooks';
import { canvasSelector } from 'features/canvas/store/canvasSelectors'; import { canvasSelector } from 'features/canvas/store/canvasSelectors';
import { GroupConfig } from 'konva/lib/Group'; import { GroupConfig } from 'konva/lib/Group';
import { isEqual } from 'lodash-es'; import { isEqual } from 'lodash-es';
import { memo } from 'react';
import { Group, Rect } from 'react-konva'; import { Group, Rect } from 'react-konva';
import IAICanvasImage from './IAICanvasImage'; import IAICanvasImage from './IAICanvasImage';
import { memo } from 'react';
const selector = createSelector( const selector = createSelector(
[canvasSelector], [canvasSelector],
@ -15,11 +14,11 @@ const selector = createSelector(
layerState, layerState,
shouldShowStagingImage, shouldShowStagingImage,
shouldShowStagingOutline, shouldShowStagingOutline,
boundingBoxCoordinates: { x, y }, boundingBoxCoordinates: stageBoundingBoxCoordinates,
boundingBoxDimensions: { width, height }, boundingBoxDimensions: stageBoundingBoxDimensions,
} = canvas; } = canvas;
const { selectedImageIndex, images } = layerState.stagingArea; const { selectedImageIndex, images, boundingBox } = layerState.stagingArea;
return { return {
currentStagingAreaImage: currentStagingAreaImage:
@ -30,10 +29,10 @@ const selector = createSelector(
isOnLastImage: selectedImageIndex === images.length - 1, isOnLastImage: selectedImageIndex === images.length - 1,
shouldShowStagingImage, shouldShowStagingImage,
shouldShowStagingOutline, shouldShowStagingOutline,
x, x: boundingBox?.x ?? stageBoundingBoxCoordinates.x,
y, y: boundingBox?.y ?? stageBoundingBoxCoordinates.y,
width, width: boundingBox?.width ?? stageBoundingBoxDimensions.width,
height, height: boundingBox?.height ?? stageBoundingBoxDimensions.height,
}; };
}, },
{ {