@netless/forge-whiteboard 1.3.0 → 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.
|
@@ -5,12 +5,15 @@ import { LiveCursor } from '../../LiveCursor';
|
|
|
5
5
|
export declare class ImageModel extends ElementModel {
|
|
6
6
|
item: paper.Raster | null;
|
|
7
7
|
private imageSets;
|
|
8
|
+
private imageElement;
|
|
9
|
+
private imageLoadVersion;
|
|
8
10
|
protected clearLocalPointsWhenYPointsChange: boolean;
|
|
9
11
|
protected shouldUseLocalPoints: boolean;
|
|
10
12
|
protected localPointsPick: number;
|
|
11
13
|
private get src();
|
|
12
14
|
constructor(root: Y.Map<any>, scope: paper.PaperScope, imageSets: HTMLDivElement, liveCursor: LiveCursor, isPerformanceMode: () => boolean);
|
|
13
15
|
protected subDispose(): void;
|
|
16
|
+
private bindImageLoad;
|
|
14
17
|
protected createPaperItem(): void;
|
|
15
18
|
protected onVectorUpdate(): void;
|
|
16
19
|
vectorKeys(): string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageModel.d.ts","sourceRoot":"","sources":["../../../src/model/renderable/ImageModel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,qBAAa,UAAW,SAAQ,YAAY;IAEnC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,IAAI,CAAQ;IAExC,OAAO,CAAC,SAAS,CAAiB;IAClC,SAAS,CAAC,iCAAiC,UAAQ;IACnD,SAAS,CAAC,oBAAoB,UAAQ;IACtC,SAAS,CAAC,eAAe,SAAK;IAE9B,OAAO,KAAK,GAAG,GAEd;gBAEkB,IAAI,EAAE,CAAC,CAA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gBAAgB,CAAC,GAAG,EAAE,MAAM;IAW/B,YAAY,IAAI,YAAY;IAQnC,SAAS,CAAC,cAAc,IAAI,GAAG;IAI/B,SAAS,CAAC,eAAe,IAAI,IAAI;CAGlC"}
|
package/dist/whiteboard.esm.js
CHANGED
|
@@ -28041,6 +28041,8 @@ var ImageModel = class extends ElementModel {
|
|
|
28041
28041
|
super(root, scope, liveCursor, isPerformanceMode);
|
|
28042
28042
|
_defineProperty16(this, "item", null);
|
|
28043
28043
|
_defineProperty16(this, "imageSets", void 0);
|
|
28044
|
+
_defineProperty16(this, "imageElement", null);
|
|
28045
|
+
_defineProperty16(this, "imageLoadVersion", 0);
|
|
28044
28046
|
_defineProperty16(this, "clearLocalPointsWhenYPointsChange", true);
|
|
28045
28047
|
_defineProperty16(this, "shouldUseLocalPoints", true);
|
|
28046
28048
|
_defineProperty16(this, "localPointsPick", 4);
|
|
@@ -28051,22 +28053,44 @@ var ImageModel = class extends ElementModel {
|
|
|
28051
28053
|
this.root.set(ElementModel.KEYS.shadow, "");
|
|
28052
28054
|
}
|
|
28053
28055
|
subDispose() {
|
|
28056
|
+
this.imageLoadVersion++;
|
|
28057
|
+
if (this.imageElement) {
|
|
28058
|
+
this.imageElement.onload = null;
|
|
28059
|
+
this.imageElement.onerror = null;
|
|
28060
|
+
this.imageElement.remove();
|
|
28061
|
+
this.imageElement = null;
|
|
28062
|
+
return;
|
|
28063
|
+
}
|
|
28054
28064
|
const img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
28055
28065
|
if (img) {
|
|
28066
|
+
img.onload = null;
|
|
28067
|
+
img.onerror = null;
|
|
28056
28068
|
img.remove();
|
|
28057
28069
|
}
|
|
28058
28070
|
}
|
|
28071
|
+
bindImageLoad(img) {
|
|
28072
|
+
const loadVersion = ++this.imageLoadVersion;
|
|
28073
|
+
img.onload = () => {
|
|
28074
|
+
if (this.imageLoadVersion !== loadVersion || !this.item) {
|
|
28075
|
+
return;
|
|
28076
|
+
}
|
|
28077
|
+
};
|
|
28078
|
+
img.onerror = null;
|
|
28079
|
+
}
|
|
28059
28080
|
createPaperItem() {
|
|
28060
28081
|
if (this.item) {
|
|
28061
28082
|
return;
|
|
28062
28083
|
}
|
|
28063
|
-
|
|
28064
|
-
|
|
28084
|
+
let img = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
28085
|
+
if (!img) {
|
|
28086
|
+
img = document.createElement("img");
|
|
28065
28087
|
img.crossOrigin = "anonymous";
|
|
28066
|
-
img.src = this.src;
|
|
28067
28088
|
img.id = this.uuid;
|
|
28068
28089
|
this.imageSets.appendChild(img);
|
|
28069
28090
|
}
|
|
28091
|
+
this.imageElement = img;
|
|
28092
|
+
this.bindImageLoad(img);
|
|
28093
|
+
img.src = this.src;
|
|
28070
28094
|
this.item = new this.scope.Raster(this.uuid);
|
|
28071
28095
|
const matrix = new this.scope.Matrix(this.pointsMatrix);
|
|
28072
28096
|
this.item.matrix = matrix;
|
|
@@ -28089,8 +28113,10 @@ var ImageModel = class extends ElementModel {
|
|
|
28089
28113
|
}
|
|
28090
28114
|
onStyleKeyUpdate(key) {
|
|
28091
28115
|
if (key === "src") {
|
|
28092
|
-
const imgElement = this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
28116
|
+
const imgElement = this.imageElement ?? this.imageSets.querySelector(`[id='${this.uuid}']`);
|
|
28093
28117
|
if (imgElement) {
|
|
28118
|
+
this.imageElement = imgElement;
|
|
28119
|
+
this.bindImageLoad(imgElement);
|
|
28094
28120
|
imgElement.src = this.src;
|
|
28095
28121
|
}
|
|
28096
28122
|
}
|