@acorex/components 21.0.3-next.15 → 21.0.3-next.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -535,12 +535,17 @@ class AXImageEditorViewComponent extends MXBaseComponent {
535
535
  return;
536
536
  }
537
537
  const cropRect = cropper.getCropperArea();
538
- const canvasRect = this.canvasElem().nativeElement.getClientRects()[0];
539
- const dx = cropRect.x - canvasRect.x;
540
- const dy = cropRect.y - canvasRect.y;
541
- const imageData = this.ctx().getImageData(dx, dy, cropRect.width, cropRect.height);
542
- this.canvasElem().nativeElement.width = cropRect.width;
543
- this.canvasElem().nativeElement.height = cropRect.height;
538
+ const canvas = this.canvasElem().nativeElement;
539
+ const canvasRect = canvas.getBoundingClientRect();
540
+ const scaleX = canvas.width / canvasRect.width;
541
+ const scaleY = canvas.height / canvasRect.height;
542
+ const dx = (cropRect.x - canvasRect.x) * scaleX;
543
+ const dy = (cropRect.y - canvasRect.y) * scaleY;
544
+ const cropWidth = cropRect.width * scaleX;
545
+ const cropHeight = cropRect.height * scaleY;
546
+ const imageData = this.ctx().getImageData(Math.round(dx), Math.round(dy), Math.round(cropWidth), Math.round(cropHeight));
547
+ canvas.width = Math.round(cropWidth);
548
+ canvas.height = Math.round(cropHeight);
544
549
  this.ctx().putImageData(imageData, 0, 0);
545
550
  const cropImage = this.canvasElem().nativeElement.toDataURL('image/jpeg', 1);
546
551
  await this.saveImageChange();
@@ -634,7 +639,7 @@ class AXImageEditorContainerComponent extends classes((MXInputBaseValueComponent
634
639
  await this.view()?.crop();
635
640
  const blobs = this.service.imageBlob();
636
641
  if (blobs.length && this.value === oldValue) {
637
- this.emitOnValueChangedEvent(oldValue, blobs);
642
+ this.commitValue(blobs, true);
638
643
  }
639
644
  }
640
645
  get __hostClass() {