refboard: anchor crop apply to selected region

This commit is contained in:
Hiren Kangad
2026-03-13 12:42:16 +05:30
parent 267deefc10
commit 50dbb4e0cf
2 changed files with 9 additions and 7 deletions
+3 -4
View File
@@ -477,17 +477,16 @@ export function useCanvasSetup(deps: CanvasSetupDeps) {
onCropModeChange?.(active);
};
cropOverlay.onConfirm = (item, crop) => {
cropOverlay.onConfirm = (item, crop, anchorWorld) => {
const imgData = item.data as any;
const before = getItemWorldBounds(item);
const isFullImage = crop.x < 0.001 && crop.y < 0.001 && crop.w > 0.999 && crop.h > 0.999;
imgData.crop = isFullImage ? undefined : crop;
if (item.displayObject instanceof ImageSprite) {
item.displayObject.applyCrop(imgData.crop);
}
const after = getItemWorldBounds(item);
imgData.x += before.x - after.x;
imgData.y += before.y - after.y;
imgData.x += anchorWorld.x - after.x;
imgData.y += anchorWorld.y - after.y;
if (item.type === 'image') {
applyImageDisplayTransform(item.displayObject, imgData);
}