@libs-ui/components-image-editor 0.2.304 → 0.2.306-3

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.
@@ -281,10 +281,10 @@ class LibsUiComponentsImageEditorComponent {
281
281
  this.linkImageError = linkImageError;
282
282
  }
283
283
  ngAfterViewInit() {
284
- if (this.aspectRatio()) {
284
+ const aspectRatioFound = this.aspectRatio()?.key ? this.cropRatioItems().find(item => item.key === this.aspectRatio()?.key) : this.cropRatioItems()[0];
285
+ if (aspectRatioFound) {
285
286
  this.dragGridCrop.set(true);
286
- const aspectRatioFound = this.cropRatioItems().find(item => item.key === this.aspectRatio()?.key);
287
- this.cropRatioItemSelected.set(aspectRatioFound?.key || this.cropRatioItems()[0].key);
287
+ this.cropRatioItemSelected.set(aspectRatioFound?.key);
288
288
  this.updateOriginImageSize();
289
289
  this.changedImage(true);
290
290
  }
@@ -426,11 +426,11 @@ class LibsUiComponentsImageEditorComponent {
426
426
  this.setStylesElements(this.cropArea(), { width, height, top, left });
427
427
  }
428
428
  getCropRatioValue() {
429
- const cropRatio = this.aspectRatio() || this.cropRatioItems().find(item => item.key === this.cropRatioItemSelected());
430
- if (!cropRatio) {
431
- return this.originWidth() / this.originHeight();
429
+ const cropRatio = this.cropRatioItems().find(item => item.key === this.cropRatioItemSelected());
430
+ if (!cropRatio?.value) {
431
+ return this.aspectRatio()?.value || (this.originWidth() / this.originHeight());
432
432
  }
433
- return cropRatio.value ?? 0;
433
+ return cropRatio.value;
434
434
  }
435
435
  updateRectClipPos() {
436
436
  const reactClip = this.getRectClipImage();