@inweb/markup 25.10.1 → 25.11.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.
@@ -1004,33 +1004,21 @@ class KonvaMarkup {
1004
1004
  this._konvaStage.height(height);
1005
1005
  };
1006
1006
  this.pan = event => {
1007
- const pointer = this._konvaStage.getPointerPosition();
1008
- const pointTo = {
1009
- x: (pointer.x - this._konvaStage.x()) / this._konvaStage.scaleX(),
1010
- y: (pointer.y - this._konvaStage.y()) / this._konvaStage.scaleX()
1011
- };
1012
1007
  const newPos = {
1013
- x: pointer.x - pointTo.x * this._konvaStage.scale().x + event.dX,
1014
- y: pointer.y - pointTo.y * this._konvaStage.scale().x + event.dY
1008
+ x: this._konvaStage.x() + event.dX,
1009
+ y: this._konvaStage.y() + event.dY
1015
1010
  };
1016
1011
  this._konvaStage.position(newPos);
1017
1012
  };
1018
1013
  this.zoomAt = event => {
1019
- const oldScale = this._konvaStage.scaleX();
1020
- const pointer = this._konvaStage.getPointerPosition();
1021
- const mousePointTo = {
1022
- x: (pointer.x - this._konvaStage.x()) / oldScale,
1023
- y: (pointer.y - this._konvaStage.y()) / oldScale
1024
- };
1025
- const direction = event.data > 0 ? 1 : -1;
1026
- const newScale = direction > 0 ? oldScale * event.data : oldScale / event.data;
1014
+ const newScale = this._konvaStage.scaleX() * event.data;
1027
1015
  this._konvaStage.scale({
1028
1016
  x: newScale,
1029
1017
  y: newScale
1030
1018
  });
1031
1019
  const newPos = {
1032
- x: pointer.x - mousePointTo.x * newScale,
1033
- y: pointer.y - mousePointTo.y * newScale
1020
+ x: event.x - (event.x - this._konvaStage.x()) * event.data,
1021
+ y: event.y - (event.y - this._konvaStage.y()) * event.data
1034
1022
  };
1035
1023
  this._konvaStage.position(newPos);
1036
1024
  };
@@ -1056,6 +1044,7 @@ class KonvaMarkup {
1056
1044
  this._markupContainer.style.top = "0px";
1057
1045
  this._markupContainer.style.left = "0px";
1058
1046
  this._markupContainer.style.outline = "0px";
1047
+ this._markupContainer.style.pointerEvents = "none";
1059
1048
  const parentDiv = this._container.parentElement;
1060
1049
  parentDiv.appendChild(this._markupContainer);
1061
1050
  this._resizeObserver = new ResizeObserver(this.resizeContainer);
@@ -1063,7 +1052,6 @@ class KonvaMarkup {
1063
1052
  this._markupColor.setColor(255, 0, 0);
1064
1053
  this.initializeKonva();
1065
1054
  if (this._viewer) {
1066
- this._containerEvents.forEach((x => this._markupContainer.addEventListener(x, this.redirectToViewer)));
1067
1055
  this._viewer.addEventListener("changeactivedragger", this.changeActiveDragger);
1068
1056
  this._viewer.addEventListener("pan", this.pan);
1069
1057
  this._viewer.addEventListener("zoomat", this.zoomAt);
@@ -1075,7 +1063,6 @@ class KonvaMarkup {
1075
1063
  this._viewer.removeEventListener("zoomat", this.zoomAt);
1076
1064
  this._viewer.removeEventListener("pan", this.pan);
1077
1065
  this._viewer.removeEventListener("changeactivedragger", this.changeActiveDragger);
1078
- this._containerEvents.forEach((x => this._markupContainer.removeEventListener(x, this.redirectToViewer)));
1079
1066
  }
1080
1067
  this.destroyKonva();
1081
1068
  (_a = this._resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
@@ -1099,6 +1086,14 @@ class KonvaMarkup {
1099
1086
  }
1100
1087
  setMarkupColor(r, g, b) {
1101
1088
  this._markupColor.setColor(r, g, b);
1089
+ this._viewer.emit({
1090
+ type: "changemarkupcolor",
1091
+ data: {
1092
+ r: r,
1093
+ g: g,
1094
+ b: b
1095
+ }
1096
+ });
1102
1097
  }
1103
1098
  colorizeAllMarkup(r, g, b) {
1104
1099
  const hexColor = new MarkupColor(r, g, b).asHex();
@@ -1168,8 +1163,8 @@ class KonvaMarkup {
1168
1163
  this.addImage(screenPoint, image.src, image.width, image.height, image.id);
1169
1164
  }));
1170
1165
  }
1171
- getViewpoint() {
1172
- const viewpoint = {};
1166
+ getViewpoint(viewpoint) {
1167
+ if (!viewpoint) viewpoint = {};
1173
1168
  viewpoint.lines = this.getMarkupLines();
1174
1169
  viewpoint.texts = this.getMarkupTexts();
1175
1170
  viewpoint.arrows = this.getMarkupArrows();
@@ -1183,7 +1178,6 @@ class KonvaMarkup {
1183
1178
  viewpoint.snapshot = {
1184
1179
  data: this.combineMarkupWithDrawing()
1185
1180
  };
1186
- viewpoint.description = (new Date).toDateString();
1187
1181
  return viewpoint;
1188
1182
  }
1189
1183
  enableEditMode(mode) {
@@ -1191,9 +1185,11 @@ class KonvaMarkup {
1191
1185
  this.clearSelected();
1192
1186
  this.removeTextInput();
1193
1187
  this.removeImageInput();
1188
+ this._markupContainer.style.pointerEvents = "none";
1194
1189
  this._markupIsActive = false;
1195
1190
  } else {
1196
1191
  this._markupMode = mode;
1192
+ this._markupContainer.style.pointerEvents = "all";
1197
1193
  this._markupIsActive = true;
1198
1194
  }
1199
1195
  return this;