@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.
@@ -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();
@@ -1191,9 +1186,11 @@ class KonvaMarkup {
1191
1186
  this.clearSelected();
1192
1187
  this.removeTextInput();
1193
1188
  this.removeImageInput();
1189
+ this._markupContainer.style.pointerEvents = "none";
1194
1190
  this._markupIsActive = false;
1195
1191
  } else {
1196
1192
  this._markupMode = mode;
1193
+ this._markupContainer.style.pointerEvents = "all";
1197
1194
  this._markupIsActive = true;
1198
1195
  }
1199
1196
  return this;