From 8147e2b97d2e363a7ac0900f3798584db6e4df94 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sun, 6 Dec 2020 18:21:29 +0100 Subject: [PATCH] Crop editor: do not allow selections starting outside image bounds. --- public/js/crop_editor.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/public/js/crop_editor.js b/public/js/crop_editor.js index 7ab1628d..5ddd64ac 100644 --- a/public/js/crop_editor.js +++ b/public/js/crop_editor.js @@ -224,9 +224,18 @@ class CropEditor { if (this.isMoving) { return false; } + + let dragStartX = event.x - this.image_container.offsetLeft; + let dragStartY = event.y - this.image_container.offsetTop; + + if (dragStartX > this.original_image.clientWidth || + dragStartY > this.original_image.clientHeight) { + return; + } + this.isDragging = true; - this.dragStartX = event.x - this.image_container.offsetLeft; - this.dragStartY = event.y - this.image_container.offsetTop; + this.dragStartX = dragStartX; + this.dragStartY = dragStartY; } cropSelectionEnd(event) {