Constrain boundary movement to image canvas.
This commit is contained in:
parent
5e0d4df2f7
commit
2a740d8cef
@ -255,14 +255,17 @@ class CropEditor {
|
|||||||
|
|
||||||
let scaleFactor = this.getScaleFactor();
|
let scaleFactor = this.getScaleFactor();
|
||||||
|
|
||||||
this.source_x.value = parseInt(this.source_x.value) + Math.ceil((this.dragEndX - this.dragStartX) * scaleFactor);
|
let x = parseInt(this.source_x.value) + Math.ceil((this.dragEndX - this.dragStartX) * scaleFactor);
|
||||||
this.source_y.value = parseInt(this.source_y.value) + Math.ceil((this.dragEndY - this.dragStartY) * scaleFactor);
|
if (x + parseInt(this.crop_width.value) > this.original_image.naturalWidth) {
|
||||||
|
x += this.original_image.naturalWidth - (x + parseInt(this.crop_width.value));
|
||||||
|
}
|
||||||
|
this.source_x.value = Math.max(x, 0);
|
||||||
|
|
||||||
// let width = Math.ceil(Math.abs(this.dragEndX - this.dragStartX) * scaleFactor);
|
let y = parseInt(this.source_y.value) + Math.ceil((this.dragEndY - this.dragStartY) * scaleFactor);
|
||||||
// this.crop_width.value = Math.min(width, this.original_image.naturalWidth - this.source_x.value);
|
if (y + parseInt(this.crop_height.value) > this.original_image.naturalHeight) {
|
||||||
|
y += this.original_image.naturalHeight - (y + parseInt(this.crop_height.value));
|
||||||
// let height = Math.ceil(Math.abs(this.dragEndY - this.dragStartY) * scaleFactor);
|
}
|
||||||
// this.crop_height.value = Math.min(height, this.original_image.naturalHeight - this.source_y.value);
|
this.source_y.value = Math.max(y, 0);
|
||||||
|
|
||||||
this.positionBoundary();
|
this.positionBoundary();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user