refboard: use full image geometry in crop mode
This commit is contained in:
@@ -120,7 +120,7 @@ export class CropOverlay extends Container {
|
|||||||
if (!this._item) return;
|
if (!this._item) return;
|
||||||
const item = this._item;
|
const item = this._item;
|
||||||
const crop = { ...this._crop };
|
const crop = { ...this._crop };
|
||||||
const data = item.data as ImageObject;
|
const data = this._getWorkingImageData();
|
||||||
const viewCrop = this._getViewCrop();
|
const viewCrop = this._getViewCrop();
|
||||||
const anchorWorld = imageViewPointToWorld(data, viewCrop.x, viewCrop.y);
|
const anchorWorld = imageViewPointToWorld(data, viewCrop.x, viewCrop.y);
|
||||||
const isFullImage = crop.x < 0.001 && crop.y < 0.001 && crop.w > 0.999 && crop.h > 0.999;
|
const isFullImage = crop.x < 0.001 && crop.y < 0.001 && crop.w > 0.999 && crop.h > 0.999;
|
||||||
@@ -162,7 +162,7 @@ export class CropOverlay extends Container {
|
|||||||
|
|
||||||
private _draw(): void {
|
private _draw(): void {
|
||||||
if (!this._item) return;
|
if (!this._item) return;
|
||||||
const data = this._item.data as ImageObject;
|
const data = this._getWorkingImageData();
|
||||||
const zoom = this._viewport.scale.x;
|
const zoom = this._viewport.scale.x;
|
||||||
const viewCrop = this._getViewCrop();
|
const viewCrop = this._getViewCrop();
|
||||||
const fullCorners = getImageViewRectWorldCorners(data, { x: 0, y: 0, w: 1, h: 1 });
|
const fullCorners = getImageViewRectWorldCorners(data, { x: 0, y: 0, w: 1, h: 1 });
|
||||||
@@ -241,7 +241,7 @@ export class CropOverlay extends Container {
|
|||||||
if ('preventDefault' in e.nativeEvent && typeof e.nativeEvent.preventDefault === 'function') {
|
if ('preventDefault' in e.nativeEvent && typeof e.nativeEvent.preventDefault === 'function') {
|
||||||
e.nativeEvent.preventDefault();
|
e.nativeEvent.preventDefault();
|
||||||
}
|
}
|
||||||
const data = this._item.data as ImageObject;
|
const data = this._getWorkingImageData();
|
||||||
const world = this._viewport.toWorld(e.global.x, e.global.y);
|
const world = this._viewport.toWorld(e.global.x, e.global.y);
|
||||||
const viewPoint = worldToImageViewPoint(data, world.x, world.y);
|
const viewPoint = worldToImageViewPoint(data, world.x, world.y);
|
||||||
this._drag = {
|
this._drag = {
|
||||||
@@ -260,7 +260,7 @@ export class CropOverlay extends Container {
|
|||||||
private _onMoveScreen(screenX: number, screenY: number): void {
|
private _onMoveScreen(screenX: number, screenY: number): void {
|
||||||
if (!this._drag || !this._item) return;
|
if (!this._drag || !this._item) return;
|
||||||
|
|
||||||
const data = this._item.data as ImageObject;
|
const data = this._getWorkingImageData();
|
||||||
const world = this._viewport.toWorld(screenX, screenY);
|
const world = this._viewport.toWorld(screenX, screenY);
|
||||||
const viewPoint = worldToImageViewPoint(data, world.x, world.y);
|
const viewPoint = worldToImageViewPoint(data, world.x, world.y);
|
||||||
const nx = clamp01(viewPoint.x);
|
const nx = clamp01(viewPoint.x);
|
||||||
@@ -389,4 +389,12 @@ export class CropOverlay extends Container {
|
|||||||
y: clientY - rect.top,
|
y: clientY - rect.top,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private _getWorkingImageData(): ImageObject {
|
||||||
|
const data = this._item!.data as ImageObject;
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
crop: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user