@inweb/markup 25.9.8 → 25.11.0
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/markup.js +12 -22
- package/dist/markup.js.map +1 -1
- package/dist/markup.min.js +1 -1
- package/dist/markup.module.js +16 -19
- package/dist/markup.module.js.map +1 -1
- package/lib/markup/IMarkup.d.ts +1 -1
- package/package.json +3 -3
- package/src/markup/IMarkup.ts +1 -1
- package/src/markup/Konva/KonvaMarkup.ts +12 -29
package/lib/markup/IMarkup.d.ts
CHANGED
|
@@ -58,7 +58,7 @@ export interface IMarkup {
|
|
|
58
58
|
*/
|
|
59
59
|
clearOverlay(): void;
|
|
60
60
|
/**
|
|
61
|
-
* Sets the color of new markup objects.
|
|
61
|
+
* Sets the default color of new markup objects.
|
|
62
62
|
*
|
|
63
63
|
* @param r - The `red` component of the color, as a number between 0 and 255.
|
|
64
64
|
* @param g - The `green` component of the color, as a number between 0 and 255.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inweb/markup",
|
|
3
|
-
"version": "25.
|
|
3
|
+
"version": "25.11.0",
|
|
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.
|
|
30
|
-
"@inweb/viewer-core": "~25.
|
|
29
|
+
"@inweb/eventemitter2": "~25.11.0",
|
|
30
|
+
"@inweb/viewer-core": "~25.11.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"konva": "^9.3.14"
|
package/src/markup/IMarkup.ts
CHANGED
|
@@ -95,7 +95,7 @@ export interface IMarkup {
|
|
|
95
95
|
clearOverlay(): void;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* Sets the color of new markup objects.
|
|
98
|
+
* Sets the default color of new markup objects.
|
|
99
99
|
*
|
|
100
100
|
* @param r - The `red` component of the color, as a number between 0 and 255.
|
|
101
101
|
* @param g - The `green` component of the color, as a number between 0 and 255.
|
|
@@ -137,8 +137,8 @@ export class KonvaMarkup implements IMarkup {
|
|
|
137
137
|
this._markupContainer.style.position = "absolute";
|
|
138
138
|
this._markupContainer.style.top = "0px";
|
|
139
139
|
this._markupContainer.style.left = "0px";
|
|
140
|
-
// to eliminate grey box during delete elements
|
|
141
|
-
this._markupContainer.style.
|
|
140
|
+
this._markupContainer.style.outline = "0px"; // <- to eliminate grey box during delete elements
|
|
141
|
+
this._markupContainer.style.pointerEvents = "none";
|
|
142
142
|
|
|
143
143
|
const parentDiv = this._container.parentElement;
|
|
144
144
|
parentDiv.appendChild(this._markupContainer);
|
|
@@ -151,7 +151,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
151
151
|
this.initializeKonva();
|
|
152
152
|
|
|
153
153
|
if (this._viewer) {
|
|
154
|
-
this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
154
|
+
// this._containerEvents.forEach((x) => this._markupContainer.addEventListener(x, this.redirectToViewer));
|
|
155
155
|
this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
|
|
156
156
|
this._viewer.addEventListener("pan", this.pan);
|
|
157
157
|
this._viewer.addEventListener("zoomat", this.zoomAt);
|
|
@@ -163,7 +163,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
163
163
|
this._viewer.removeEventListener("zoomat", this.zoomAt);
|
|
164
164
|
this._viewer.removeEventListener("pan", this.pan);
|
|
165
165
|
this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
|
|
166
|
-
this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
|
|
166
|
+
// this._containerEvents.forEach((x) => this._markupContainer.removeEventListener(x, this.redirectToViewer));
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
this.destroyKonva();
|
|
@@ -208,40 +208,20 @@ export class KonvaMarkup implements IMarkup {
|
|
|
208
208
|
};
|
|
209
209
|
|
|
210
210
|
pan = (event: PanEvent) => {
|
|
211
|
-
const pointer = this._konvaStage.getPointerPosition();
|
|
212
|
-
|
|
213
|
-
const pointTo = {
|
|
214
|
-
x: (pointer.x - this._konvaStage.x()) / this._konvaStage.scaleX(),
|
|
215
|
-
y: (pointer.y - this._konvaStage.y()) / this._konvaStage.scaleX(),
|
|
216
|
-
};
|
|
217
|
-
|
|
218
211
|
const newPos = {
|
|
219
|
-
x:
|
|
220
|
-
y:
|
|
212
|
+
x: this._konvaStage.x() + event.dX,
|
|
213
|
+
y: this._konvaStage.y() + event.dY,
|
|
221
214
|
};
|
|
222
|
-
|
|
223
215
|
this._konvaStage.position(newPos);
|
|
224
216
|
};
|
|
225
217
|
|
|
226
218
|
zoomAt = (event: ZoomAtEvent) => {
|
|
227
|
-
const
|
|
228
|
-
const pointer = this._konvaStage.getPointerPosition();
|
|
229
|
-
|
|
230
|
-
const mousePointTo = {
|
|
231
|
-
x: (pointer.x - this._konvaStage.x()) / oldScale,
|
|
232
|
-
y: (pointer.y - this._konvaStage.y()) / oldScale,
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
// how to scale? Zoom in? Or zoom out?
|
|
236
|
-
const direction = event.data > 0 ? 1 : -1;
|
|
237
|
-
|
|
238
|
-
const newScale = direction > 0 ? oldScale * event.data : oldScale / event.data;
|
|
239
|
-
|
|
219
|
+
const newScale = this._konvaStage.scaleX() * event.data;
|
|
240
220
|
this._konvaStage.scale({ x: newScale, y: newScale });
|
|
241
221
|
|
|
242
222
|
const newPos = {
|
|
243
|
-
x:
|
|
244
|
-
y:
|
|
223
|
+
x: event.x - (event.x - this._konvaStage.x()) * event.data,
|
|
224
|
+
y: event.y - (event.y - this._konvaStage.y()) * event.data,
|
|
245
225
|
};
|
|
246
226
|
this._konvaStage.position(newPos);
|
|
247
227
|
};
|
|
@@ -265,6 +245,7 @@ export class KonvaMarkup implements IMarkup {
|
|
|
265
245
|
|
|
266
246
|
setMarkupColor(r: number, g: number, b: number): void {
|
|
267
247
|
this._markupColor.setColor(r, g, b);
|
|
248
|
+
this._viewer.emit({ type: "changemarkupcolor", data: { r, g, b } });
|
|
268
249
|
}
|
|
269
250
|
|
|
270
251
|
colorizeAllMarkup(r: number, g: number, b: number): void {
|
|
@@ -352,9 +333,11 @@ export class KonvaMarkup implements IMarkup {
|
|
|
352
333
|
this.clearSelected();
|
|
353
334
|
this.removeTextInput();
|
|
354
335
|
this.removeImageInput();
|
|
336
|
+
this._markupContainer.style.pointerEvents = "none";
|
|
355
337
|
this._markupIsActive = false;
|
|
356
338
|
} else {
|
|
357
339
|
this._markupMode = mode;
|
|
340
|
+
this._markupContainer.style.pointerEvents = "all";
|
|
358
341
|
this._markupIsActive = true;
|
|
359
342
|
}
|
|
360
343
|
return this;
|