From 67ea66f394cdbf43831e0410b9fc36e3406d1a4f Mon Sep 17 00:00:00 2001 From: nd0ut Date: Fri, 10 Mar 2023 11:52:12 +0400 Subject: [PATCH] fix(cloud-editor): refetch image on container resize --- blocks/CloudImageEditor/src/EditorImageCropper.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/blocks/CloudImageEditor/src/EditorImageCropper.js b/blocks/CloudImageEditor/src/EditorImageCropper.js index 50f752606..abd4cf1f2 100644 --- a/blocks/CloudImageEditor/src/EditorImageCropper.js +++ b/blocks/CloudImageEditor/src/EditorImageCropper.js @@ -93,10 +93,8 @@ export class EditorImageCropper extends Block { if (!this.isConnected) { return; } - this._initCanvas(); - this._alignImage(); - this._alignCrop(); - this._draw(); + this.deactivate(); + this.activate(this._imageSize, { fromViewer: false }); } /** @private */ @@ -493,8 +491,9 @@ export class EditorImageCropper extends Block { initCallback() { super.initCallback(); - this._observer = new ResizeObserver(() => { - if (this._isActive && this.$.image) { + this._observer = new ResizeObserver(([entry]) => { + const nonZeroSize = entry.contentRect.width > 0 && entry.contentRect.height > 0; + if (nonZeroSize && this._isActive && this.$.image) { this._handleResizeDebounced(); } });