Skip to content

Commit

Permalink
Merge pull request #607 from uploadcare/fix/cloud-editor-glitches
Browse files Browse the repository at this point in the history
fix(cloud-image-editor): weird ui glitches when updating `cdnUrl` on change
  • Loading branch information
nd0ut authored Feb 15, 2024
2 parents 9a763e6 + c264c64 commit 3b00343
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
33 changes: 20 additions & 13 deletions blocks/CloudImageEditor/src/CloudImageEditorBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,33 @@ export class CloudImageEditorBlock extends CloudImageEditorBase {
}
await this._waitForSize();

if (this.$['*tabId'] === TabId.CROP) {
this.$['*cropperEl'].deactivate({ reset: true });
} else {
this.$['*faderEl'].deactivate();
}

this.$['*editorTransformations'] = {};

if (this.$.cdnUrl) {
let uuid = extractUuid(this.$.cdnUrl);
this.$['*originalUrl'] = createOriginalUrl(this.$.cdnUrl, uuid);
let operations = extractOperations(this.$.cdnUrl);
let transformations = operationsToTransformations(operations);
const uuid = extractUuid(this.$.cdnUrl);
const originalUrl = createOriginalUrl(this.$.cdnUrl, uuid);
if (originalUrl === this.$['*originalUrl']) {
return;
}
this.$['*originalUrl'] = originalUrl;
const operations = extractOperations(this.$.cdnUrl);
const transformations = operationsToTransformations(operations);
this.$['*editorTransformations'] = transformations;
} else if (this.$.uuid) {
this.$['*originalUrl'] = createOriginalUrl(this.cfg.cdnCname, this.$.uuid);
const originalUrl = createOriginalUrl(this.cfg.cdnCname, this.$.uuid);
if (originalUrl === this.$['*originalUrl']) {
return;
}
this.$['*originalUrl'] = originalUrl;
this.$['*editorTransformations'] = {};
} else {
throw new Error('No UUID nor CDN URL provided');
}

if (this.$['*tabId'] === TabId.CROP) {
this.$['*cropperEl'].deactivate({ reset: true });
} else {
this.$['*faderEl'].deactivate();
}

try {
const cdnUrl = createCdnUrl(this.$['*originalUrl'], createCdnUrlModifiers('json'));
const json = await fetch(cdnUrl).then((response) => response.json());
Expand Down
1 change: 0 additions & 1 deletion blocks/CloudImageEditor/src/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@
height: 100%;
overflow: hidden;
overflow-y: auto;
transition: 0.3s;
}

@media only screen and (max-width: 800px) {
Expand Down

0 comments on commit 3b00343

Please sign in to comment.