Make crop editor usable #22

Merged
Aaron merged 27 commits from crop-editor into master 2020-12-30 20:06:17 +01:00
Showing only changes of commit 2a740d8cef - Show all commits

View File

@ -255,14 +255,17 @@ class CropEditor {
let scaleFactor = this.getScaleFactor();
this.source_x.value = 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);
let x = parseInt(this.source_x.value) + Math.ceil((this.dragEndX - this.dragStartX) * 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);
// this.crop_width.value = Math.min(width, this.original_image.naturalWidth - this.source_x.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);
let y = parseInt(this.source_y.value) + Math.ceil((this.dragEndY - this.dragStartY) * scaleFactor);
if (y + parseInt(this.crop_height.value) > this.original_image.naturalHeight) {
y += this.original_image.naturalHeight - (y + parseInt(this.crop_height.value));
}
this.source_y.value = Math.max(y, 0);
this.positionBoundary();
}