@netless/forge-slide 1.3.0-beta.1 → 1.3.1
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.
- package/dist/slide.esm.js +30 -4
- package/dist/slide.esm.js.map +2 -2
- package/dist/slide.js +30 -4
- package/dist/slide.js.map +2 -2
- package/package.json +3 -3
package/dist/slide.esm.js
CHANGED
|
@@ -63297,6 +63297,8 @@ var ImageModel = class extends ElementModel {
|
|
|
63297
63297
|
super(root, scope, liveCursor, isPerformanceMode);
|
|
63298
63298
|
_defineProperty16(this, "item", null);
|
|
63299
63299
|
_defineProperty16(this, "imageSets", void 0);
|
|
63300
|
+
_defineProperty16(this, "imageElement", null);
|
|
63301
|
+
_defineProperty16(this, "imageLoadVersion", 0);
|
|
63300
63302
|
_defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
|
|
63301
63303
|
_defineProperty16(this, "shouldUseLocalPoints", true);
|
|
63302
63304
|
_defineProperty16(this, "localPointsPick", 4);
|
|
@@ -63307,22 +63309,44 @@ var ImageModel = class extends ElementModel {
|
|
|
63307
63309
|
this.root.set(ElementModel.KEYS.shadow, "");
|
|
63308
63310
|
}
|
|
63309
63311
|
subDispose() {
|
|
63312
|
+
this.imageLoadVersion++;
|
|
63313
|
+
if (this.imageElement) {
|
|
63314
|
+
this.imageElement.onload = null;
|
|
63315
|
+
this.imageElement.onerror = null;
|
|
63316
|
+
this.imageElement.remove();
|
|
63317
|
+
this.imageElement = null;
|
|
63318
|
+
return;
|
|
63319
|
+
}
|
|
63310
63320
|
const img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
63311
63321
|
if (img) {
|
|
63322
|
+
img.onload = null;
|
|
63323
|
+
img.onerror = null;
|
|
63312
63324
|
img.remove();
|
|
63313
63325
|
}
|
|
63314
63326
|
}
|
|
63327
|
+
bindImageLoad(img) {
|
|
63328
|
+
const loadVersion = ++this.imageLoadVersion;
|
|
63329
|
+
img.onload = () => {
|
|
63330
|
+
if (this.imageLoadVersion !== loadVersion || !this.item) {
|
|
63331
|
+
return;
|
|
63332
|
+
}
|
|
63333
|
+
};
|
|
63334
|
+
img.onerror = null;
|
|
63335
|
+
}
|
|
63315
63336
|
createPaperItem() {
|
|
63316
63337
|
if (this.item) {
|
|
63317
63338
|
return;
|
|
63318
63339
|
}
|
|
63319
|
-
|
|
63320
|
-
|
|
63340
|
+
let img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
63341
|
+
if (!img) {
|
|
63342
|
+
img = document.createElement("img");
|
|
63321
63343
|
img.crossOrigin = "anonymous";
|
|
63322
|
-
img.src = this.src;
|
|
63323
63344
|
img.id = this.uuid;
|
|
63324
63345
|
this.imageSets.appendChild(img);
|
|
63325
63346
|
}
|
|
63347
|
+
this.imageElement = img;
|
|
63348
|
+
this.bindImageLoad(img);
|
|
63349
|
+
img.src = this.src;
|
|
63326
63350
|
this.item = new this.scope.Raster(this.uuid);
|
|
63327
63351
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
63328
63352
|
this.item.matrix = matrix;
|
|
@@ -63345,8 +63369,10 @@ var ImageModel = class extends ElementModel {
|
|
|
63345
63369
|
}
|
|
63346
63370
|
onStyleKeyUpdate(key) {
|
|
63347
63371
|
if (key === "src") {
|
|
63348
|
-
const imgElement = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
63372
|
+
const imgElement = this.imageElement ?? this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
63349
63373
|
if (imgElement) {
|
|
63374
|
+
this.imageElement = imgElement;
|
|
63375
|
+
this.bindImageLoad(imgElement);
|
|
63350
63376
|
imgElement.src = this.src;
|
|
63351
63377
|
}
|
|
63352
63378
|
}
|