use `$change` instead of changing all values individually, for each value the `$chang...
authorCyperghost <olaf_schmitz_1@t-online.de>
Fri, 20 Dec 2024 09:14:19 +0000 (10:14 +0100)
committerCyperghost <olaf_schmitz_1@t-online.de>
Fri, 20 Dec 2024 09:14:19 +0000 (10:14 +0100)
ts/WoltLabSuite/Core/Component/Image/Cropper.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Component/Image/Cropper.js

index 3b230dc3e639732c12fcd16386026afbd286aec6..4c1048249d893f32a5840e7c3a8cb5e892ef8dc6 100644 (file)
@@ -234,21 +234,22 @@ abstract class ImageCropper {
       const maxSelection: Selection = {
         x: 0,
         y: 0,
-        width: this.cropperCanvasRect!.width,
-        height: this.cropperCanvasRect!.height,
+        width: this.cropperCanvasRect.width,
+        height: this.cropperCanvasRect.height,
       };
 
       if (!inSelection(selection, maxSelection)) {
         event.preventDefault();
 
         // Clamp the position to the boundaries of the canvas.
-        this.cropperSelection!.x = clampValue(selection.x, selection.width, maxSelection.width);
-        this.cropperSelection!.y = clampValue(selection.y, selection.height, maxSelection.height);
-
-        this.cropperSelection!.width = selection.width;
-        this.cropperSelection!.height = selection.height;
-
-        this.cropperSelection!.$render();
+        void this.cropperSelection!.$nextTick().then(() => {
+          this.cropperSelection!.$change(
+            clampValue(selection.x, selection.width, maxSelection.width),
+            clampValue(selection.y, selection.height, maxSelection.height),
+            selection.width,
+            selection.height,
+          );
+        });
       }
     });
   }
index 28648311ed1b9f5f00930195e9b1c07022465d12..4d8597286f88db084ad3186306e74468ea00408c 100644 (file)
@@ -181,11 +181,9 @@ define(["require", "exports", "tslib", "WoltLabSuite/Core/Image/Resizer", "WoltL
                 if (!inSelection(selection, maxSelection)) {
                     event.preventDefault();
                     // Clamp the position to the boundaries of the canvas.
-                    this.cropperSelection.x = clampValue(selection.x, selection.width, maxSelection.width);
-                    this.cropperSelection.y = clampValue(selection.y, selection.height, maxSelection.height);
-                    this.cropperSelection.width = selection.width;
-                    this.cropperSelection.height = selection.height;
-                    this.cropperSelection.$render();
+                    void this.cropperSelection.$nextTick().then(() => {
+                        this.cropperSelection.$change(clampValue(selection.x, selection.width, maxSelection.width), clampValue(selection.y, selection.height, maxSelection.height), selection.width, selection.height);
+                    });
                 }
             });
         }