@inweb/markup 25.7.7 → 25.7.8
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/markup",
|
|
3
|
-
"version": "25.7.
|
|
3
|
+
"version": "25.7.8",
|
|
4
4
|
"description": "JavaScript 2D markups",
|
|
5
5
|
"homepage": "https://cloud.opendesign.com/docs/index.html",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"docs": "typedoc"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@inweb/eventemitter2": "~25.7.
|
|
30
|
-
"@inweb/viewer-core": "~25.7.
|
|
29
|
+
"@inweb/eventemitter2": "~25.7.8",
|
|
30
|
+
"@inweb/viewer-core": "~25.7.8"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"canvas": "^2.11.2",
|
|
@@ -102,6 +102,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
102
102
|
private _imageInputRef: HTMLInputElement;
|
|
103
103
|
private _imageInputPos: Konva.Vector2d;
|
|
104
104
|
private _markupContainer: HTMLDivElement;
|
|
105
|
+
private _resizeObserver: ResizeObserver;
|
|
105
106
|
private _zIndex = 1;
|
|
106
107
|
|
|
107
108
|
private readonly _markupContainerName = "markupContainer";
|
|
@@ -137,15 +138,15 @@ export class KonvaMarkup implements IMarkup {
|
|
|
137
138
|
const parentDiv = this._container.parentElement;
|
|
138
139
|
parentDiv.appendChild(this._markupContainer);
|
|
139
140
|
|
|
141
|
+
this._resizeObserver = new ResizeObserver(this.resizeContainer);
|
|
142
|
+
this._resizeObserver.observe(parentDiv);
|
|
143
|
+
|
|
140
144
|
this._markupColor.setColor(255, 0, 0);
|
|
141
145
|
|
|
142
146
|
this.initializeKonva();
|
|
143
|
-
this.resize();
|
|
144
147
|
|
|
145
148
|
if (this._viewer) {
|
|
146
149
|
this._pointerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
147
|
-
|
|
148
|
-
this._viewer.addEventListener("resize", this.resize);
|
|
149
150
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
150
151
|
this._viewer.addEventListener("pan", this.pan);
|
|
151
152
|
}
|
|
@@ -159,13 +160,15 @@ export class KonvaMarkup implements IMarkup {
|
|
|
159
160
|
if (this._viewer) {
|
|
160
161
|
this._viewer.removeEventListener("pan", this.pan);
|
|
161
162
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
162
|
-
this._viewer.removeEventListener("resize", this.resize);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
165
|
this._pointerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
|
|
166
166
|
|
|
167
167
|
this.destroyKonva();
|
|
168
168
|
|
|
169
|
+
this._resizeObserver.disconnect();
|
|
170
|
+
this._resizeObserver = undefined;
|
|
171
|
+
|
|
169
172
|
this._markupContainer.remove();
|
|
170
173
|
this._markupContainer = undefined;
|
|
171
174
|
|
|
@@ -200,9 +203,13 @@ export class KonvaMarkup implements IMarkup {
|
|
|
200
203
|
}
|
|
201
204
|
};
|
|
202
205
|
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
resizeContainer = (entries: ResizeObserverEntry[]) => {
|
|
207
|
+
const { width, height } = entries[0].contentRect;
|
|
208
|
+
|
|
209
|
+
if (!width || !height) return; // <- invisible container, or container with parent removed
|
|
210
|
+
|
|
211
|
+
this._konvaStage?.width(width);
|
|
212
|
+
this._konvaStage?.height(height);
|
|
206
213
|
};
|
|
207
214
|
|
|
208
215
|
pan = (event: PanEvent) => {
|