kritzel-stencil 0.0.107 → 0.0.109

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.
Files changed (117) hide show
  1. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +858 -820
  2. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil.cjs.js +1 -1
  5. package/dist/collection/classes/handlers/context-menu.handler.js +2 -47
  6. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  7. package/dist/collection/classes/handlers/key.handler.js +1 -1
  8. package/dist/collection/classes/handlers/key.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/move.handler.js +62 -55
  10. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/resize.handler.js +122 -113
  12. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/rotation.handler.js +74 -66
  14. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  15. package/dist/collection/classes/handlers/selection.handler.js +59 -50
  16. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  17. package/dist/collection/classes/objects/base-object.class.js +3 -0
  18. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  19. package/dist/collection/classes/objects/text.class.js +11 -1
  20. package/dist/collection/classes/objects/text.class.js.map +1 -1
  21. package/dist/collection/classes/registries/icon-registry.class.js.map +1 -0
  22. package/dist/collection/classes/registries/tool.registry.js.map +1 -0
  23. package/dist/collection/classes/store.class.js +3 -54
  24. package/dist/collection/classes/store.class.js.map +1 -1
  25. package/dist/collection/classes/tools/base-tool.class.js +3 -18
  26. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  27. package/dist/collection/classes/tools/brush-tool.class.js +79 -71
  28. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  29. package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
  30. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  31. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  32. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  33. package/dist/collection/classes/tools/selection-tool.class.js +94 -74
  34. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  35. package/dist/collection/classes/tools/text-tool.class.js +73 -70
  36. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  37. package/dist/collection/classes/viewport.class.js +76 -69
  38. package/dist/collection/classes/viewport.class.js.map +1 -1
  39. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
  40. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +2 -2
  41. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  42. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
  43. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +69 -121
  44. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  45. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +1 -1
  46. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
  47. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
  48. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  49. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
  50. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
  51. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  52. package/dist/collection/configs/default-engine-state.js +53 -0
  53. package/dist/collection/configs/default-engine-state.js.map +1 -0
  54. package/dist/collection/helpers/devices.helper.js +6 -0
  55. package/dist/collection/helpers/devices.helper.js.map +1 -0
  56. package/dist/collection/helpers/event.helper.js +43 -20
  57. package/dist/collection/helpers/event.helper.js.map +1 -1
  58. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  59. package/dist/collection/interfaces/object.interface.js.map +1 -1
  60. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  61. package/dist/components/kritzel-context-menu.js +1 -1
  62. package/dist/components/kritzel-controls.js +1 -1
  63. package/dist/components/kritzel-editor.js +6 -6
  64. package/dist/components/kritzel-editor.js.map +1 -1
  65. package/dist/components/kritzel-engine.js +1 -1
  66. package/dist/components/{p-CesjDLvT.js → p-7Ns73-wN.js} +237 -206
  67. package/dist/components/p-7Ns73-wN.js.map +1 -0
  68. package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
  69. package/dist/components/p-BmAloSfd.js.map +1 -0
  70. package/dist/components/{p-_3gCPfqz.js → p-BmrZipyu.js} +621 -622
  71. package/dist/components/p-BmrZipyu.js.map +1 -0
  72. package/dist/components/p-CZkSABuJ.js.map +1 -1
  73. package/dist/components/{p-DTcfnx4-.js → p-Ch6TgHX3.js} +18 -8
  74. package/dist/components/p-Ch6TgHX3.js.map +1 -0
  75. package/dist/esm/kritzel-brush-style_18.entry.js +858 -820
  76. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  77. package/dist/esm/loader.js +1 -1
  78. package/dist/esm/stencil.js +1 -1
  79. package/dist/stencil/p-c976660c.entry.js +2 -0
  80. package/dist/stencil/p-c976660c.entry.js.map +1 -0
  81. package/dist/stencil/stencil.esm.js +1 -1
  82. package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
  83. package/dist/types/classes/handlers/move.handler.d.ts +3 -6
  84. package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
  85. package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
  86. package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
  87. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  88. package/dist/types/classes/objects/text.class.d.ts +1 -0
  89. package/dist/types/classes/{tool.registry.d.ts → registries/tool.registry.d.ts} +2 -2
  90. package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
  91. package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
  92. package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
  93. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
  94. package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
  95. package/dist/types/classes/viewport.class.d.ts +3 -6
  96. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
  97. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
  98. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
  99. package/dist/types/components.d.ts +0 -2
  100. package/dist/types/configs/default-engine-state.d.ts +2 -0
  101. package/dist/types/helpers/devices.helper.d.ts +3 -0
  102. package/dist/types/helpers/event.helper.d.ts +2 -4
  103. package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
  104. package/dist/types/interfaces/object.interface.d.ts +1 -0
  105. package/dist/types/interfaces/tool.interface.d.ts +3 -8
  106. package/package.json +1 -1
  107. package/dist/collection/classes/icon-registry.class.js.map +0 -1
  108. package/dist/collection/classes/tool.registry.js.map +0 -1
  109. package/dist/components/p-Cbu5RSmC.js.map +0 -1
  110. package/dist/components/p-CesjDLvT.js.map +0 -1
  111. package/dist/components/p-DTcfnx4-.js.map +0 -1
  112. package/dist/components/p-_3gCPfqz.js.map +0 -1
  113. package/dist/stencil/p-e596d004.entry.js +0 -2
  114. package/dist/stencil/p-e596d004.entry.js.map +0 -1
  115. /package/dist/collection/classes/{icon-registry.class.js → registries/icon-registry.class.js} +0 -0
  116. /package/dist/collection/classes/{tool.registry.js → registries/tool.registry.js} +0 -0
  117. /package/dist/types/classes/{icon-registry.class.d.ts → registries/icon-registry.class.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { p as proxyCustomElement, H, c as createEvent, h, d as Host } from './p-DC8SDK2U.js';
2
- import { b as KritzelBaseCommand, c as KritzelBaseTool, d as KritzelEventHelper, e as KritzelBaseObject, f as KritzelText, g as KritzelToolRegistry, a as KritzelTextTool, K as KritzelBrushTool, h as KritzelPath, O as ObjectHelper, A as AddObjectCommand, i as KritzelKeyboardHelper } from './p-CesjDLvT.js';
3
- import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-Cbu5RSmC.js';
2
+ import { b as KritzelBaseCommand, c as KritzelBaseTool, d as KritzelEventHelper, e as KritzelBaseObject, f as KritzelText, g as KritzelToolRegistry, a as KritzelTextTool, K as KritzelBrushTool, h as KritzelPath, O as ObjectHelper, A as AddObjectCommand, i as KritzelMouseButton, j as KritzelKeyboardHelper } from './p-7Ns73-wN.js';
3
+ import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-BmAloSfd.js';
4
4
  import { d as defineCustomElement$2 } from './p-Ds3FhuuO.js';
5
5
  import { d as defineCustomElement$1 } from './p-CZkSABuJ.js';
6
6
 
@@ -35,71 +35,76 @@ class KritzelEraserTool extends KritzelBaseTool {
35
35
  super(store);
36
36
  this.touchStartTimeout = null;
37
37
  }
38
- handleMouseDown(event) {
39
- if (KritzelEventHelper.isLeftClick(event)) {
40
- this._store.state.isErasing = true;
38
+ handlePointerDown(event) {
39
+ if (event.pointerType === 'mouse') {
40
+ if (KritzelEventHelper.isLeftClick(event)) {
41
+ this._store.state.isErasing = true;
42
+ }
41
43
  }
42
- }
43
- handleMouseMove(event) {
44
- var _a;
45
- if (this._store.state.isErasing) {
46
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
47
- if (!shadowRoot)
48
- return;
49
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
50
- if (!selectedObject)
51
- return;
52
- selectedObject.markedForRemoval = true;
53
- this._store.rerender();
44
+ if (event.pointerType === 'touch') {
45
+ this.touchStartTimeout = setTimeout(() => {
46
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling) {
47
+ this._store.state.isErasing = true;
48
+ }
49
+ }, 80);
54
50
  }
55
51
  }
56
- handleMouseUp(_event) {
57
- if (this._store.state.isErasing) {
58
- const removeCommands = this._store.allObjects
59
- .filter(object => object.markedForRemoval)
60
- .map(object => {
61
- object.markedForRemoval = false;
62
- return new RemoveObjectCommand(this._store, this, object);
63
- });
64
- if (removeCommands.length > 0) {
65
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
52
+ handlePointerMove(event) {
53
+ var _a, _b;
54
+ if (event.pointerType === 'mouse') {
55
+ if (this._store.state.isErasing) {
56
+ const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
57
+ if (!shadowRoot)
58
+ return;
59
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
60
+ if (!selectedObject)
61
+ return;
62
+ selectedObject.markedForRemoval = true;
63
+ this._store.rerender();
66
64
  }
67
- this._store.state.isErasing = false;
68
65
  }
69
- }
70
- handleTouchStart(_event) {
71
- this.touchStartTimeout = setTimeout(() => {
72
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling) {
73
- this._store.state.isErasing = true;
66
+ if (event.pointerType === 'touch') {
67
+ if (this._store.state.pointers.size === 1 && this._store.state.isErasing) {
68
+ const shadowRoot = (_b = this._store.state.host) === null || _b === void 0 ? void 0 : _b.shadowRoot;
69
+ if (!shadowRoot)
70
+ return;
71
+ const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
72
+ if (!selectedObject)
73
+ return;
74
+ selectedObject.markedForRemoval = true;
75
+ this._store.rerender();
74
76
  }
75
- }, 80);
76
- }
77
- handleTouchMove(event) {
78
- var _a;
79
- if (this._store.state.touchCount === 1 && this._store.state.isErasing) {
80
- const shadowRoot = (_a = this._store.state.host) === null || _a === void 0 ? void 0 : _a.shadowRoot;
81
- if (!shadowRoot)
82
- return;
83
- const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
84
- if (!selectedObject)
85
- return;
86
- selectedObject.markedForRemoval = true;
87
- this._store.rerender();
88
77
  }
89
78
  }
90
- handleTouchEnd(_event) {
91
- clearTimeout(this.touchStartTimeout);
92
- if (this._store.state.isErasing) {
93
- const removeCommands = this._store.allObjects
94
- .filter(object => object.markedForRemoval)
95
- .map(object => {
96
- object.markedForRemoval = false;
97
- return new RemoveObjectCommand(this._store, this, object);
98
- });
99
- if (removeCommands.length > 0) {
100
- this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
79
+ handlePointerUp(event) {
80
+ if (event.pointerType === 'mouse') {
81
+ if (this._store.state.isErasing) {
82
+ const removeCommands = this._store.allObjects
83
+ .filter(object => object.markedForRemoval)
84
+ .map(object => {
85
+ object.markedForRemoval = false;
86
+ return new RemoveObjectCommand(this._store, this, object);
87
+ });
88
+ if (removeCommands.length > 0) {
89
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
90
+ }
91
+ this._store.state.isErasing = false;
92
+ }
93
+ }
94
+ if (event.pointerType === 'touch') {
95
+ clearTimeout(this.touchStartTimeout);
96
+ if (this._store.state.isErasing) {
97
+ const removeCommands = this._store.allObjects
98
+ .filter(object => object.markedForRemoval)
99
+ .map(object => {
100
+ object.markedForRemoval = false;
101
+ return new RemoveObjectCommand(this._store, this, object);
102
+ });
103
+ if (removeCommands.length > 0) {
104
+ this._store.history.executeCommand(new BatchCommand(this._store, this, removeCommands));
105
+ }
106
+ this._store.state.isErasing = false;
101
107
  }
102
- this._store.state.isErasing = false;
103
108
  }
104
109
  }
105
110
  }
@@ -186,72 +191,79 @@ class KritzelMoveHandler extends KritzelBaseHandler {
186
191
  constructor(store) {
187
192
  super(store);
188
193
  }
189
- handleMouseDown(event) {
190
- var _a;
191
- if (KritzelEventHelper.isLeftClick(event)) {
192
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
194
+ handlePointerDown(event) {
195
+ var _a, _b;
196
+ if (event.pointerType === 'mouse') {
197
+ if (KritzelEventHelper.isLeftClick(event)) {
198
+ if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
199
+ const clientX = event.clientX - this._store.offsetX;
200
+ const clientY = event.clientY - this._store.offsetY;
201
+ this._store.state.isDragging = true;
202
+ this.dragStartX = clientX;
203
+ this.dragStartY = clientY;
204
+ this.startX = this.dragStartX;
205
+ this.startY = this.dragStartY;
206
+ }
207
+ }
208
+ }
209
+ if (event.pointerType === 'touch') {
210
+ const activePointers = Array.from(this._store.state.pointers.values());
211
+ if (this._store.state.pointers.size === 1) {
212
+ if (((_b = this._store.state.selectionGroup) === null || _b === void 0 ? void 0 : _b.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
213
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
214
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
215
+ this.dragStartX = x;
216
+ this.dragStartY = y;
217
+ this.startX = x;
218
+ this.startY = y;
219
+ }
220
+ }
221
+ }
222
+ }
223
+ handlePointerMove(event) {
224
+ if (event.pointerType === 'mouse') {
225
+ if (this._store.state.isDragging && this._store.state.selectionGroup) {
193
226
  const clientX = event.clientX - this._store.offsetX;
194
227
  const clientY = event.clientY - this._store.offsetY;
195
- this._store.state.isDragging = true;
228
+ this.endX = clientX;
229
+ this.endY = clientY;
230
+ this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
196
231
  this.dragStartX = clientX;
197
232
  this.dragStartY = clientY;
198
- this.startX = this.dragStartX;
199
- this.startY = this.dragStartY;
200
233
  }
201
234
  }
202
- }
203
- handleMouseMove(event) {
204
- if (this._store.state.isDragging && this._store.state.selectionGroup) {
205
- const clientX = event.clientX - this._store.offsetX;
206
- const clientY = event.clientY - this._store.offsetY;
207
- this.endX = clientX;
208
- this.endY = clientY;
209
- this._store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
210
- this.dragStartX = clientX;
211
- this.dragStartY = clientY;
212
- }
213
- }
214
- handleMouseUp(_event) {
215
- if (this._store.state.isDragging) {
216
- this._store.state.isDragging = false;
217
- this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
235
+ if (event.pointerType === 'touch') {
236
+ const activePointers = Array.from(this._store.state.pointers.values());
237
+ if (this._store.state.pointers.size === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
238
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
239
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
240
+ this._store.state.isDragging = true;
241
+ this.endX = x;
242
+ this.endY = y;
243
+ const moveDeltaX = Math.abs(x - this.startX);
244
+ const moveDeltaY = Math.abs(y - this.startY);
245
+ const moveThreshold = 5;
246
+ if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
247
+ clearTimeout(this._store.state.longTouchTimeout);
248
+ this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
249
+ this.dragStartX = x;
250
+ this.dragStartY = y;
251
+ }
252
+ }
218
253
  }
219
254
  }
220
- handleTouchStart(event) {
221
- var _a;
222
- if (this._store.state.touchCount === 1) {
223
- if (((_a = this._store.state.selectionGroup) === null || _a === void 0 ? void 0 : _a.selected) && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
224
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
225
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
226
- this.dragStartX = x;
227
- this.dragStartY = y;
228
- this.startX = x;
229
- this.startY = y;
230
- }
231
- }
232
- }
233
- handleTouchMove(event) {
234
- if (this._store.state.touchCount === 1 && this._store.state.selectionGroup && !this._store.state.isResizeHandleSelected && !this._store.state.isRotationHandleSelected) {
235
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
236
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
237
- this._store.state.isDragging = true;
238
- this.endX = x;
239
- this.endY = y;
240
- const moveDeltaX = Math.abs(x - this.startX);
241
- const moveDeltaY = Math.abs(y - this.startY);
242
- const moveThreshold = 5;
243
- if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
244
- clearTimeout(this._store.state.longTouchTimeout);
245
- this._store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);
246
- this.dragStartX = x;
247
- this.dragStartY = y;
255
+ handlePointerUp(event) {
256
+ if (event.pointerType === 'mouse') {
257
+ if (this._store.state.isDragging) {
258
+ this._store.state.isDragging = false;
259
+ this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
248
260
  }
249
261
  }
250
- }
251
- handleTouchEnd(_event) {
252
- if (this._store.state.isDragging) {
253
- this._store.state.isDragging = false;
254
- this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
262
+ if (event.pointerType === 'touch') {
263
+ if (this._store.state.isDragging) {
264
+ this._store.state.isDragging = false;
265
+ this._store.history.executeCommand(new MoveSelectionGroupCommand(this._store, this, this.endX, this.endY, this.startX, this.startY, true));
266
+ }
255
267
  }
256
268
  }
257
269
  }
@@ -289,131 +301,140 @@ class KritzelResizeHandler extends KritzelBaseHandler {
289
301
  this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
290
302
  this.newSize = { x: 0, y: 0, width: 0, height: 0 };
291
303
  }
292
- handleMouseDown(event) {
293
- if (KritzelEventHelper.isLeftClick(event)) {
294
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
295
- const clientX = event.clientX - this._store.offsetX;
296
- const clientY = event.clientY - this._store.offsetY;
297
- this._store.state.isResizing = true;
298
- this.initialMouseX = clientX;
299
- this.initialMouseY = clientY;
300
- this.initialSize.width = this._store.state.selectionGroup.width;
301
- this.initialSize.height = this._store.state.selectionGroup.height;
302
- this.initialSize.x = this._store.state.selectionGroup.translateX;
303
- this.initialSize.y = this._store.state.selectionGroup.translateY;
304
- }
305
- }
306
- }
307
- handleMouseMove(event) {
308
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
309
- const clientX = event.clientX - this._store.offsetX;
310
- const clientY = event.clientY - this._store.offsetY;
311
- const dx = clientX - this.initialMouseX;
312
- const dy = clientY - this.initialMouseY;
313
- switch (this._store.state.resizeHandleType) {
314
- case KritzelHandleType.TopLeft:
315
- this.newSize.width = this.initialSize.width - dx;
316
- this.newSize.height = this.initialSize.height - dy;
317
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
318
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
319
- break;
320
- case KritzelHandleType.TopRight:
321
- this.newSize.width = this.initialSize.width + dx;
322
- this.newSize.height = this.initialSize.height - dy;
323
- this.newSize.x = this.initialSize.x;
324
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
325
- break;
326
- case KritzelHandleType.BottomLeft:
327
- this.newSize.width = this.initialSize.width - dx;
328
- this.newSize.height = this.initialSize.height + dy;
329
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
330
- this.newSize.y = this.initialSize.y;
331
- break;
332
- case KritzelHandleType.BottomRight:
333
- this.newSize.width = this.initialSize.width + dx;
334
- this.newSize.height = this.initialSize.height + dy;
335
- this.newSize.x = this.initialSize.x;
336
- this.newSize.y = this.initialSize.y;
337
- break;
338
- }
339
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
340
- this._store.rerender();
304
+ handlePointerDown(event) {
305
+ if (event.pointerType === 'mouse') {
306
+ if (KritzelEventHelper.isLeftClick(event)) {
307
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
308
+ const clientX = event.clientX - this._store.offsetX;
309
+ const clientY = event.clientY - this._store.offsetY;
310
+ this._store.state.isResizing = true;
311
+ this.initialMouseX = clientX;
312
+ this.initialMouseY = clientY;
313
+ this.initialSize.width = this._store.state.selectionGroup.width;
314
+ this.initialSize.height = this._store.state.selectionGroup.height;
315
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
316
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
317
+ }
318
+ }
341
319
  }
342
- }
343
- handleMouseUp(_event) {
344
- if (this._store.state.isResizing) {
345
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
346
- this._store.history.executeCommand(resizeSelectionGroupCommand);
347
- this._store.state.isResizing = false;
348
- this._store.rerender();
320
+ if (event.pointerType === 'touch') {
321
+ const activePointers = Array.from(this._store.state.pointers.values());
322
+ const firstTouch = activePointers[0];
323
+ if (!firstTouch) {
324
+ return;
325
+ }
326
+ if (activePointers.length === 1) {
327
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
328
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
329
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
330
+ this._store.state.isResizing = true;
331
+ this.initialMouseX = clientX;
332
+ this.initialMouseY = clientY;
333
+ this.initialSize.width = this._store.state.selectionGroup.width;
334
+ this.initialSize.height = this._store.state.selectionGroup.height;
335
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
336
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
337
+ clearTimeout(this._store.state.longTouchTimeout);
338
+ }
339
+ }
349
340
  }
350
341
  }
351
- handleTouchStart(event) {
352
- const firstTouch = event.touches[0];
353
- if (!firstTouch) {
354
- return;
342
+ handlePointerMove(event) {
343
+ if (event.pointerType === 'mouse') {
344
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
345
+ const clientX = event.clientX - this._store.offsetX;
346
+ const clientY = event.clientY - this._store.offsetY;
347
+ const dx = clientX - this.initialMouseX;
348
+ const dy = clientY - this.initialMouseY;
349
+ switch (this._store.state.resizeHandleType) {
350
+ case KritzelHandleType.TopLeft:
351
+ this.newSize.width = this.initialSize.width - dx;
352
+ this.newSize.height = this.initialSize.height - dy;
353
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
354
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
355
+ break;
356
+ case KritzelHandleType.TopRight:
357
+ this.newSize.width = this.initialSize.width + dx;
358
+ this.newSize.height = this.initialSize.height - dy;
359
+ this.newSize.x = this.initialSize.x;
360
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
361
+ break;
362
+ case KritzelHandleType.BottomLeft:
363
+ this.newSize.width = this.initialSize.width - dx;
364
+ this.newSize.height = this.initialSize.height + dy;
365
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
366
+ this.newSize.y = this.initialSize.y;
367
+ break;
368
+ case KritzelHandleType.BottomRight:
369
+ this.newSize.width = this.initialSize.width + dx;
370
+ this.newSize.height = this.initialSize.height + dy;
371
+ this.newSize.x = this.initialSize.x;
372
+ this.newSize.y = this.initialSize.y;
373
+ break;
374
+ }
375
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
376
+ this._store.rerender();
377
+ }
355
378
  }
356
- if (this._store.state.touchCount === 1) {
357
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
358
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
359
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
360
- this._store.state.isResizing = true;
361
- this.initialMouseX = clientX;
362
- this.initialMouseY = clientY;
363
- this.initialSize.width = this._store.state.selectionGroup.width;
364
- this.initialSize.height = this._store.state.selectionGroup.height;
365
- this.initialSize.x = this._store.state.selectionGroup.translateX;
366
- this.initialSize.y = this._store.state.selectionGroup.translateY;
379
+ if (event.pointerType === 'touch') {
380
+ const activePointers = Array.from(this._store.state.pointers.values());
381
+ const oneFingerTouch = activePointers[0];
382
+ if (!oneFingerTouch) {
383
+ return;
384
+ }
385
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
386
+ const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
387
+ const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
388
+ const dx = clientX - this.initialMouseX;
389
+ const dy = clientY - this.initialMouseY;
390
+ switch (this._store.state.resizeHandleType) {
391
+ case KritzelHandleType.TopLeft:
392
+ this.newSize.width = this.initialSize.width - dx;
393
+ this.newSize.height = this.initialSize.height - dy;
394
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
395
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
396
+ break;
397
+ case KritzelHandleType.TopRight:
398
+ this.newSize.width = this.initialSize.width + dx;
399
+ this.newSize.height = this.initialSize.height - dy;
400
+ this.newSize.x = this.initialSize.x;
401
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
402
+ break;
403
+ case KritzelHandleType.BottomLeft:
404
+ this.newSize.width = this.initialSize.width - dx;
405
+ this.newSize.height = this.initialSize.height + dy;
406
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
407
+ this.newSize.y = this.initialSize.y;
408
+ break;
409
+ case KritzelHandleType.BottomRight:
410
+ this.newSize.width = this.initialSize.width + dx;
411
+ this.newSize.height = this.initialSize.height + dy;
412
+ this.newSize.x = this.initialSize.x;
413
+ this.newSize.y = this.initialSize.y;
414
+ break;
415
+ }
416
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
367
417
  clearTimeout(this._store.state.longTouchTimeout);
368
418
  }
369
419
  }
370
420
  }
371
- handleTouchMove(event) {
372
- const oneFingerTouch = event.touches[0];
373
- if (!oneFingerTouch) {
374
- return;
421
+ handlePointerUp(event) {
422
+ if (event.pointerType === 'mouse') {
423
+ if (this._store.state.isResizing) {
424
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
425
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
426
+ this._store.state.isResizing = false;
427
+ this._store.rerender();
428
+ }
375
429
  }
376
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
377
- const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
378
- const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
379
- const dx = clientX - this.initialMouseX;
380
- const dy = clientY - this.initialMouseY;
381
- switch (this._store.state.resizeHandleType) {
382
- case KritzelHandleType.TopLeft:
383
- this.newSize.width = this.initialSize.width - dx;
384
- this.newSize.height = this.initialSize.height - dy;
385
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
386
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
387
- break;
388
- case KritzelHandleType.TopRight:
389
- this.newSize.width = this.initialSize.width + dx;
390
- this.newSize.height = this.initialSize.height - dy;
391
- this.newSize.x = this.initialSize.x;
392
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
393
- break;
394
- case KritzelHandleType.BottomLeft:
395
- this.newSize.width = this.initialSize.width - dx;
396
- this.newSize.height = this.initialSize.height + dy;
397
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
398
- this.newSize.y = this.initialSize.y;
399
- break;
400
- case KritzelHandleType.BottomRight:
401
- this.newSize.width = this.initialSize.width + dx;
402
- this.newSize.height = this.initialSize.height + dy;
403
- this.newSize.x = this.initialSize.x;
404
- this.newSize.y = this.initialSize.y;
405
- break;
406
- }
407
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
408
- clearTimeout(this._store.state.longTouchTimeout);
409
- }
410
- }
411
- handleTouchEnd(_event) {
412
- if (this._store.state.isResizing) {
413
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
414
- this._store.history.executeCommand(resizeSelectionGroupCommand);
415
- this._store.state.isResizing = false;
416
- clearTimeout(this._store.state.longTouchTimeout);
430
+ if (event.pointerType === 'touch') {
431
+ if (this._store.state.isResizing) {
432
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
433
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
434
+ this._store.state.isResizing = false;
435
+ this._store.rerender();
436
+ clearTimeout(this._store.state.longTouchTimeout);
437
+ }
417
438
  }
418
439
  }
419
440
  }
@@ -447,87 +468,95 @@ class KritzelRotationHandler extends KritzelBaseHandler {
447
468
  this.initialRotation = 0;
448
469
  this.rotation = 0;
449
470
  }
450
- handleMouseDown(event) {
451
- if (KritzelEventHelper.isLeftClick(event)) {
452
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
471
+ handlePointerDown(event) {
472
+ if (event.pointerType === 'mouse') {
473
+ if (KritzelEventHelper.isLeftClick(event)) {
474
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
475
+ const clientX = event.clientX - this._store.offsetX;
476
+ const clientY = event.clientY - this._store.offsetY;
477
+ this._store.state.isRotating = true;
478
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
479
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
480
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
481
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
482
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
483
+ }
484
+ }
485
+ }
486
+ if (event.pointerType === 'touch') {
487
+ const activePointers = Array.from(this._store.state.pointers.values());
488
+ const firstTouch = activePointers[0];
489
+ if (!firstTouch) {
490
+ return;
491
+ }
492
+ if (activePointers.length === 1) {
493
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
494
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
495
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
496
+ this._store.state.isRotating = true;
497
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
498
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
499
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
500
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
501
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
502
+ clearTimeout(this._store.state.longTouchTimeout);
503
+ }
504
+ }
505
+ }
506
+ }
507
+ handlePointerMove(event) {
508
+ if (event.pointerType === 'mouse') {
509
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
453
510
  const clientX = event.clientX - this._store.offsetX;
454
511
  const clientY = event.clientY - this._store.offsetY;
455
- this._store.state.isRotating = true;
456
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
457
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
512
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
513
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
458
514
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
459
515
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
460
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
516
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
517
+ this.rotation = currentRotation - this.initialRotation;
518
+ this._store.state.selectionGroup.rotate(this.rotation);
519
+ this._store.rerender();
461
520
  }
462
521
  }
463
- }
464
- handleMouseMove(event) {
465
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
466
- const clientX = event.clientX - this._store.offsetX;
467
- const clientY = event.clientY - this._store.offsetY;
468
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
469
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
470
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
471
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
472
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
473
- this.rotation = currentRotation - this.initialRotation;
474
- this._store.state.selectionGroup.rotate(this.rotation);
475
- this._store.rerender();
476
- }
477
- }
478
- handleMouseUp(_event) {
479
- if (this._store.state.isRotating) {
480
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
481
- this._store.state.isRotating = false;
482
- this.initialRotation = 0;
483
- this.rotation = 0;
484
- }
485
- }
486
- handleTouchStart(event) {
487
- const firstTouch = event.touches[0];
488
- if (!firstTouch) {
489
- return;
490
- }
491
- if (this._store.state.touchCount === 1) {
492
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
522
+ if (event.pointerType === 'touch') {
523
+ const activePointers = Array.from(this._store.state.pointers.values());
524
+ const firstTouch = activePointers[0];
525
+ if (!firstTouch) {
526
+ return;
527
+ }
528
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
493
529
  const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
494
530
  const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
495
- this._store.state.isRotating = true;
496
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
497
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
531
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
532
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
498
533
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
499
534
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
500
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
535
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
536
+ this.rotation = currentRotation - this.initialRotation;
537
+ this._store.state.selectionGroup.rotate(this.rotation);
538
+ this._store.rerender();
501
539
  clearTimeout(this._store.state.longTouchTimeout);
502
540
  }
503
541
  }
504
542
  }
505
- handleTouchMove(event) {
506
- const firstTouch = event.touches[0];
507
- if (!firstTouch) {
508
- return;
509
- }
510
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
511
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
512
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
513
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
514
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
515
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
516
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
517
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
518
- this.rotation = currentRotation - this.initialRotation;
519
- this._store.state.selectionGroup.rotate(this.rotation);
520
- this._store.rerender();
521
- clearTimeout(this._store.state.longTouchTimeout);
543
+ handlePointerUp(event) {
544
+ if (event.pointerType === 'mouse') {
545
+ if (this._store.state.isRotating) {
546
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
547
+ this._store.state.isRotating = false;
548
+ this.initialRotation = 0;
549
+ this.rotation = 0;
550
+ }
522
551
  }
523
- }
524
- handleTouchEnd(_event) {
525
- if (this._store.state.isRotating) {
526
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
527
- this._store.state.isRotating = false;
528
- this.initialRotation = 0;
529
- this.rotation = 0;
530
- clearTimeout(this._store.state.longTouchTimeout);
552
+ if (event.pointerType === 'touch') {
553
+ if (this._store.state.isRotating) {
554
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
555
+ this._store.state.isRotating = false;
556
+ this.initialRotation = 0;
557
+ this.rotation = 0;
558
+ clearTimeout(this._store.state.longTouchTimeout);
559
+ }
531
560
  }
532
561
  }
533
562
  }
@@ -635,63 +664,70 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
635
664
  this.touchStartY = 0;
636
665
  this.touchStartTimeout = null;
637
666
  }
638
- handleMouseDown(event) {
639
- if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
640
- this.startMouseSelection(event);
667
+ handlePointerDown(event) {
668
+ if (event.pointerType === 'mouse') {
669
+ if (KritzelEventHelper.isLeftClick(event) && !this._store.state.selectionGroup) {
670
+ this.startMouseSelection(event);
671
+ }
641
672
  }
642
- }
643
- handleMouseMove(event) {
644
- if (this._store.state.isSelecting) {
645
- this.updateMouseSelection(event);
673
+ if (event.pointerType === 'touch') {
674
+ this.touchStartTimeout = setTimeout(() => {
675
+ if (this._store.state.pointers.size === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
676
+ this.startTouchSelection();
677
+ this.updateTouchSelection();
678
+ }
679
+ }, 80);
646
680
  }
647
681
  }
648
- handleMouseUp(event) {
649
- if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
650
- if (this.isSelectionClick) {
651
- this.updateMouseSelection(event);
652
- this.addSelectedObjectAtIndexToSelectionGroup(0);
653
- this.removeSelectionBox();
654
- }
655
- if (this.isSelectionDrag) {
682
+ handlePointerMove(event) {
683
+ if (event.pointerType === 'mouse') {
684
+ if (this._store.state.isSelecting) {
656
685
  this.updateMouseSelection(event);
657
- this.addSelectedObjectsToSelectionGroup();
658
- this.removeSelectionBox();
659
686
  }
660
687
  }
661
- }
662
- handleTouchStart(event) {
663
- this.touchStartTimeout = setTimeout(() => {
664
- if (this._store.state.touchCount === 1 && !this._store.state.isScaling && !this._store.state.selectionGroup) {
665
- this.startTouchSelection(event);
666
- this.updateTouchSelection(event);
688
+ if (event.pointerType === 'touch') {
689
+ const activePointers = Array.from(this._store.state.pointers.values());
690
+ const x = Math.round(activePointers[0].clientX - this._store.offsetX);
691
+ const y = Math.round(activePointers[0].clientY - this._store.offsetY);
692
+ const moveDeltaX = Math.abs(x - this.touchStartX);
693
+ const moveDeltaY = Math.abs(y - this.touchStartY);
694
+ const moveThreshold = 5;
695
+ if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
696
+ this.updateTouchSelection();
697
+ clearTimeout(this._store.state.longTouchTimeout);
667
698
  }
668
- }, 80);
669
- }
670
- handleTouchMove(event) {
671
- const x = Math.round(event.touches[0].clientX - this._store.offsetX);
672
- const y = Math.round(event.touches[0].clientY - this._store.offsetY);
673
- const moveDeltaX = Math.abs(x - this.touchStartX);
674
- const moveDeltaY = Math.abs(y - this.touchStartY);
675
- const moveThreshold = 5;
676
- if ((moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) && this._store.state.isSelecting) {
677
- this.updateTouchSelection(event);
678
- clearTimeout(this._store.state.longTouchTimeout);
679
699
  }
680
700
  }
681
- handleTouchEnd(event) {
682
- clearTimeout(this.touchStartTimeout);
683
- if (this._store.state.isSelecting) {
684
- if (this.isSelectionClick) {
685
- this.updateTouchSelection(event);
686
- this.addSelectedObjectAtIndexToSelectionGroup(0);
687
- this.removeSelectionBox();
701
+ handlePointerUp(event) {
702
+ if (event.pointerType === 'mouse') {
703
+ if (KritzelEventHelper.isLeftClick(event) && this._store.state.isSelecting) {
704
+ if (this.isSelectionClick) {
705
+ this.updateMouseSelection(event);
706
+ this.addSelectedObjectAtIndexToSelectionGroup(0);
707
+ this.removeSelectionBox();
708
+ }
709
+ if (this.isSelectionDrag) {
710
+ this.updateMouseSelection(event);
711
+ this.addSelectedObjectsToSelectionGroup();
712
+ this.removeSelectionBox();
713
+ }
688
714
  }
689
- if (this.isSelectionDrag) {
690
- this.updateTouchSelection(event);
691
- this.addSelectedObjectsToSelectionGroup();
692
- this.removeSelectionBox();
715
+ }
716
+ if (event.pointerType === 'touch') {
717
+ clearTimeout(this.touchStartTimeout);
718
+ if (this._store.state.isSelecting) {
719
+ if (this.isSelectionClick) {
720
+ this.updateTouchSelection();
721
+ this.addSelectedObjectAtIndexToSelectionGroup(0);
722
+ this.removeSelectionBox();
723
+ }
724
+ if (this.isSelectionDrag) {
725
+ this.updateTouchSelection();
726
+ this.addSelectedObjectsToSelectionGroup();
727
+ this.removeSelectionBox();
728
+ }
729
+ this._store.state.skipContextMenu = false;
693
730
  }
694
- this._store.state.skipContextMenu = false;
695
731
  }
696
732
  }
697
733
  removeSelectionBox() {
@@ -715,8 +751,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
715
751
  this._store.state.objectsOctree.remove(o => o instanceof KrtizelSelectionBox || o instanceof KritzelSelectionGroup);
716
752
  this._store.state.objectsOctree.insert(selectionBox);
717
753
  }
718
- startTouchSelection(event) {
719
- const firstTouch = event.touches[0];
754
+ startTouchSelection() {
755
+ const activePointers = Array.from(this._store.state.pointers.values());
756
+ const firstTouch = activePointers[0];
720
757
  if (!firstTouch) {
721
758
  return;
722
759
  }
@@ -752,8 +789,9 @@ class KritzelSelectionHandler extends KritzelBaseHandler {
752
789
  this._store.rerender();
753
790
  }
754
791
  }
755
- updateTouchSelection(event) {
756
- const firstTouch = event.touches[0];
792
+ updateTouchSelection() {
793
+ const activePointers = Array.from(this._store.state.pointers.values());
794
+ const firstTouch = activePointers[0];
757
795
  if (!firstTouch) {
758
796
  return;
759
797
  }
@@ -819,39 +857,103 @@ class KritzelSelectionTool extends KritzelBaseTool {
819
857
  this.resizeHandler = new KritzelResizeHandler(this._store);
820
858
  this.rotationHandler = new KritzelRotationHandler(this._store);
821
859
  }
822
- handleMouseDown(event) {
823
- if (KritzelEventHelper.isLeftClick(event)) {
824
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
825
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
826
- this._store.state.resizeHandleType = this.getHandleType(event);
827
- const selectedObject = this.getSelectedObject(event);
828
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
829
- if ((selectedObject === null || isDifferentObject) &&
830
- this._store.state.selectionGroup &&
831
- !this._store.state.isResizeHandleSelected &&
832
- !this._store.state.isRotationHandleSelected) {
833
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
834
- }
835
- }
836
- this.moveHandler.handleMouseDown(event);
837
- this.selectionHandler.handleMouseDown(event);
838
- this.resizeHandler.handleMouseDown(event);
839
- this.rotationHandler.handleMouseDown(event);
840
- this._store.rerender();
841
- }
842
- handleMouseMove(event) {
843
- this.moveHandler.handleMouseMove(event);
844
- this.selectionHandler.handleMouseMove(event);
845
- this.resizeHandler.handleMouseMove(event);
846
- this.rotationHandler.handleMouseMove(event);
847
- this._store.rerender();
860
+ handlePointerDown(event) {
861
+ if (event.pointerType === 'mouse') {
862
+ if (KritzelEventHelper.isLeftClick(event)) {
863
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
864
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
865
+ this._store.state.resizeHandleType = this.getHandleType(event);
866
+ const selectedObject = this.getSelectedObject(event);
867
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
868
+ if ((selectedObject === null || isDifferentObject) &&
869
+ this._store.state.selectionGroup &&
870
+ !this._store.state.isResizeHandleSelected &&
871
+ !this._store.state.isRotationHandleSelected) {
872
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
873
+ }
874
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
875
+ setTimeout(() => {
876
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
877
+ selectedObject.objects[0].onSelectedClick();
878
+ }
879
+ }, 100);
880
+ }
881
+ }
882
+ this.moveHandler.handlePointerDown(event);
883
+ this.selectionHandler.handlePointerDown(event);
884
+ this.resizeHandler.handlePointerDown(event);
885
+ this.rotationHandler.handlePointerDown(event);
886
+ this._store.rerender();
887
+ }
888
+ if (event.pointerType === 'touch') {
889
+ if (this._store.state.isScaling === true) {
890
+ return;
891
+ }
892
+ if (this._store.state.pointers.size === 1) {
893
+ this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
894
+ this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
895
+ this._store.state.resizeHandleType = this.getHandleType(event);
896
+ const selectedObject = this.getSelectedObject(event);
897
+ const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
898
+ if (!this._store.state.selectionGroup && selectedObject) {
899
+ this._store.state.skipContextMenu = true;
900
+ }
901
+ if ((selectedObject === null || isDifferentObject) &&
902
+ this._store.state.selectionGroup &&
903
+ !this._store.state.isResizeHandleSelected &&
904
+ !this._store.state.isRotationHandleSelected) {
905
+ this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
906
+ }
907
+ if (selectedObject && selectedObject.selected && selectedObject.objects.length === 1) {
908
+ setTimeout(() => {
909
+ if (this._store.state.isDragging === false && this._store.state.isResizing === false && this._store.state.isRotating === false) {
910
+ selectedObject.objects[0].onSelectedClick();
911
+ }
912
+ }, 100);
913
+ }
914
+ }
915
+ this.rotationHandler.handlePointerDown(event);
916
+ this.resizeHandler.handlePointerDown(event);
917
+ this.moveHandler.handlePointerDown(event);
918
+ this.selectionHandler.handlePointerDown(event);
919
+ }
920
+ }
921
+ handlePointerMove(event) {
922
+ if (event.pointerType === 'mouse') {
923
+ this.moveHandler.handlePointerMove(event);
924
+ this.selectionHandler.handlePointerMove(event);
925
+ this.resizeHandler.handlePointerMove(event);
926
+ this.rotationHandler.handlePointerMove(event);
927
+ this._store.rerender();
928
+ }
929
+ if (event.pointerType === 'touch') {
930
+ if (this._store.state.isScaling === true) {
931
+ return;
932
+ }
933
+ this.rotationHandler.handlePointerMove(event);
934
+ this.resizeHandler.handlePointerMove(event);
935
+ this.moveHandler.handlePointerMove(event);
936
+ this.selectionHandler.handlePointerMove(event);
937
+ this._store.rerender();
938
+ }
848
939
  }
849
- handleMouseUp(event) {
850
- this.moveHandler.handleMouseUp(event);
851
- this.selectionHandler.handleMouseUp(event);
852
- this.resizeHandler.handleMouseUp(event);
853
- this.rotationHandler.handleMouseUp(event);
854
- this._store.rerender();
940
+ handlePointerUp(event) {
941
+ if (event.pointerType === 'mouse') {
942
+ this.moveHandler.handlePointerUp(event);
943
+ this.selectionHandler.handlePointerUp(event);
944
+ this.resizeHandler.handlePointerUp(event);
945
+ this.rotationHandler.handlePointerUp(event);
946
+ this._store.rerender();
947
+ }
948
+ if (event.pointerType === 'touch') {
949
+ if (this._store.state.isScaling === true) {
950
+ return;
951
+ }
952
+ this.rotationHandler.handlePointerUp(event);
953
+ this.resizeHandler.handlePointerUp(event);
954
+ this.moveHandler.handlePointerUp(event);
955
+ this.selectionHandler.handlePointerUp(event);
956
+ }
855
957
  }
856
958
  handleDoubleClick(event) {
857
959
  var _a;
@@ -883,50 +985,6 @@ class KritzelSelectionTool extends KritzelBaseTool {
883
985
  }, 300);
884
986
  }
885
987
  }
886
- handleTouchStart(event) {
887
- if (this._store.state.isScaling === true) {
888
- return;
889
- }
890
- if (this._store.state.touchCount === 1) {
891
- this._store.state.isResizeHandleSelected = this.isHandleSelected(event);
892
- this._store.state.isRotationHandleSelected = this.isRotationHandleSelected(event);
893
- this._store.state.resizeHandleType = this.getHandleType(event);
894
- const selectedObject = this.getSelectedObject(event);
895
- const isDifferentObject = selectedObject && this._store.state.selectionGroup && selectedObject.id !== this._store.state.selectionGroup.id;
896
- if (!this._store.state.selectionGroup && selectedObject) {
897
- this._store.state.skipContextMenu = true;
898
- }
899
- if ((selectedObject === null || isDifferentObject) &&
900
- this._store.state.selectionGroup &&
901
- !this._store.state.isResizeHandleSelected &&
902
- !this._store.state.isRotationHandleSelected) {
903
- this._store.history.executeCommand(new RemoveSelectionGroupCommand(this._store, this._store.state.selectionGroup));
904
- }
905
- }
906
- this.rotationHandler.handleTouchStart(event);
907
- this.resizeHandler.handleTouchStart(event);
908
- this.moveHandler.handleTouchStart(event);
909
- this.selectionHandler.handleTouchStart(event);
910
- }
911
- handleTouchMove(event) {
912
- if (this._store.state.isScaling === true) {
913
- return;
914
- }
915
- this.rotationHandler.handleTouchMove(event);
916
- this.resizeHandler.handleTouchMove(event);
917
- this.moveHandler.handleTouchMove(event);
918
- this.selectionHandler.handleTouchMove(event);
919
- this._store.rerender();
920
- }
921
- handleTouchEnd(event) {
922
- if (this._store.state.isScaling === true) {
923
- return;
924
- }
925
- this.rotationHandler.handleTouchEnd(event);
926
- this.resizeHandler.handleTouchEnd(event);
927
- this.moveHandler.handleTouchEnd(event);
928
- this.selectionHandler.handleTouchEnd(event);
929
- }
930
988
  getSelectedObject(event) {
931
989
  const path = event.composedPath().slice(1);
932
990
  const objectElement = path.find(element => element.classList && element.classList.contains('object'));
@@ -1306,85 +1364,91 @@ class KritzelViewport {
1306
1364
  this._store.state.hasViewportChanged = true;
1307
1365
  this._store.rerender();
1308
1366
  }
1309
- handleMouseDown(event) {
1310
- const adjustedClientX = event.clientX - this._store.offsetX;
1311
- const adjustedClientY = event.clientY - this._store.offsetY;
1312
- if (KritzelEventHelper.isRightClick(event)) {
1313
- this._store.state.isPanning = true;
1314
- this._store.state.startX = adjustedClientX;
1315
- this._store.state.startY = adjustedClientY;
1316
- }
1317
- }
1318
- handleMouseMove(event) {
1319
- const adjustedClientX = event.clientX - this._store.offsetX;
1320
- const adjustedClientY = event.clientY - this._store.offsetY;
1321
- this._store.state.cursorX = adjustedClientX;
1322
- this._store.state.cursorY = adjustedClientY;
1323
- if (this._store.state.isPanning) {
1324
- this._store.state.translateX -= this._store.state.startX - adjustedClientX;
1325
- this._store.state.translateY -= this._store.state.startY - adjustedClientY;
1326
- this._store.state.startX = adjustedClientX;
1327
- this._store.state.startY = adjustedClientY;
1328
- this._store.state.hasViewportChanged = true;
1329
- this._store.state.skipContextMenu = true;
1330
- this._store.rerender();
1367
+ handlePointerDown(event) {
1368
+ if (event.pointerType === 'mouse') {
1369
+ const adjustedClientX = event.clientX - this._store.offsetX;
1370
+ const adjustedClientY = event.clientY - this._store.offsetY;
1371
+ if (event.button === KritzelMouseButton.Right) {
1372
+ this._store.state.isPanning = true;
1373
+ this._store.state.startX = adjustedClientX;
1374
+ this._store.state.startY = adjustedClientY;
1375
+ }
1331
1376
  }
1332
- }
1333
- handleMouseUp(_event) {
1334
- if (this._store.state.isPanning) {
1335
- this._store.state.isPanning = false;
1336
- this._store.rerender();
1377
+ if (event.pointerType === 'touch') {
1378
+ const activePointers = Array.from(this._store.state.pointers.values());
1379
+ if (activePointers.length === 2) {
1380
+ this._store.state.currentPath = null;
1381
+ this._store.state.isScaling = true;
1382
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
1383
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
1384
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
1385
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
1386
+ this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
1387
+ this.startX = (firstTouchX + secondTouchX) / 2;
1388
+ this.startY = (firstTouchY + secondTouchY) / 2;
1389
+ this._store.rerender();
1390
+ }
1337
1391
  }
1338
1392
  }
1339
- handleTouchStart(event) {
1340
- this._store.state.touchCount = event.touches.length;
1341
- if (this._store.state.touchCount === 2) {
1342
- this._store.state.currentPath = null;
1343
- this._store.state.isScaling = true;
1344
- const firstTouchX = event.touches[0].clientX - this._store.offsetX;
1345
- const firstTouchY = event.touches[0].clientY - this._store.offsetY;
1346
- const secondTouchX = event.touches[1].clientX - this._store.offsetX;
1347
- const secondTouchY = event.touches[1].clientY - this._store.offsetY;
1348
- this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
1349
- this.startX = (firstTouchX + secondTouchX) / 2;
1350
- this.startY = (firstTouchY + secondTouchY) / 2;
1351
- this._store.rerender();
1393
+ handlePointerMove(event) {
1394
+ if (event.pointerType === 'mouse') {
1395
+ const adjustedClientX = event.clientX - this._store.offsetX;
1396
+ const adjustedClientY = event.clientY - this._store.offsetY;
1397
+ this._store.state.cursorX = adjustedClientX;
1398
+ this._store.state.cursorY = adjustedClientY;
1399
+ if (this._store.state.isPanning) {
1400
+ this._store.state.translateX -= this._store.state.startX - adjustedClientX;
1401
+ this._store.state.translateY -= this._store.state.startY - adjustedClientY;
1402
+ this._store.state.startX = adjustedClientX;
1403
+ this._store.state.startY = adjustedClientY;
1404
+ this._store.state.hasViewportChanged = true;
1405
+ this._store.state.skipContextMenu = true;
1406
+ this._store.rerender();
1407
+ }
1408
+ }
1409
+ if (event.pointerType === 'touch') {
1410
+ const activePointers = Array.from(this._store.state.pointers.values());
1411
+ if (activePointers.length === 2) {
1412
+ const firstTouchX = activePointers[0].clientX - this._store.offsetX;
1413
+ const firstTouchY = activePointers[0].clientY - this._store.offsetY;
1414
+ const secondTouchX = activePointers[1].clientX - this._store.offsetX;
1415
+ const secondTouchY = activePointers[1].clientY - this._store.offsetY;
1416
+ const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
1417
+ const midpointX = (firstTouchX + secondTouchX) / 2;
1418
+ const midpointY = (firstTouchY + secondTouchY) / 2;
1419
+ const scaleRatio = currentTouchDistance / this.initialTouchDistance;
1420
+ const newScale = this._store.state.scale * scaleRatio;
1421
+ if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
1422
+ this._store.state.translateX += midpointX - this.startX;
1423
+ this._store.state.translateY += midpointY - this.startY;
1424
+ }
1425
+ else {
1426
+ const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
1427
+ const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
1428
+ this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
1429
+ this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
1430
+ this._store.state.scale = newScale;
1431
+ this.initialTouchDistance = currentTouchDistance;
1432
+ }
1433
+ this.startX = midpointX;
1434
+ this.startY = midpointY;
1435
+ this._store.state.hasViewportChanged = true;
1436
+ this._store.rerender();
1437
+ }
1352
1438
  }
1353
1439
  }
1354
- handleTouchMove(event) {
1355
- if (this._store.state.touchCount === 2) {
1356
- const firstTouchX = event.touches[0].clientX - this._store.offsetX;
1357
- const firstTouchY = event.touches[0].clientY - this._store.offsetY;
1358
- const secondTouchX = event.touches[1].clientX - this._store.offsetX;
1359
- const secondTouchY = event.touches[1].clientY - this._store.offsetY;
1360
- const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));
1361
- const midpointX = (firstTouchX + secondTouchX) / 2;
1362
- const midpointY = (firstTouchY + secondTouchY) / 2;
1363
- const scaleRatio = currentTouchDistance / this.initialTouchDistance;
1364
- const newScale = this._store.state.scale * scaleRatio;
1365
- if (newScale > this._store.state.scaleMax || newScale < this._store.state.scaleMin) {
1366
- this._store.state.translateX += midpointX - this.startX;
1367
- this._store.state.translateY += midpointY - this.startY;
1440
+ handlePointerUp(event) {
1441
+ if (event.pointerType === 'mouse') {
1442
+ if (this._store.state.isPanning) {
1443
+ this._store.state.isPanning = false;
1444
+ this._store.rerender();
1368
1445
  }
1369
- else {
1370
- const translateXAdjustment = (midpointX - this._store.state.translateX) * (scaleRatio - 1);
1371
- const translateYAdjustment = (midpointY - this._store.state.translateY) * (scaleRatio - 1);
1372
- this._store.state.translateX += midpointX - this.startX - translateXAdjustment;
1373
- this._store.state.translateY += midpointY - this.startY - translateYAdjustment;
1374
- this._store.state.scale = newScale;
1375
- this.initialTouchDistance = currentTouchDistance;
1376
- }
1377
- this.startX = midpointX;
1378
- this.startY = midpointY;
1379
- this._store.state.hasViewportChanged = true;
1446
+ }
1447
+ if (event.pointerType === 'touch') {
1448
+ this._store.state.isScaling = false;
1380
1449
  this._store.rerender();
1381
1450
  }
1382
1451
  }
1383
- handleTouchEnd(_event) {
1384
- this._store.state.touchCount = 0;
1385
- this._store.state.isScaling = false;
1386
- this._store.rerender();
1387
- }
1388
1452
  handleWheel(event) {
1389
1453
  event.preventDefault();
1390
1454
  if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {
@@ -1691,7 +1755,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
1691
1755
  }
1692
1756
  }
1693
1757
 
1694
- const initialState = {
1758
+ const DEFAULT_ENGINE_STATE = {
1695
1759
  activeTool: null,
1696
1760
  activeText: null,
1697
1761
  currentPath: null,
@@ -1739,10 +1803,11 @@ const initialState = {
1739
1803
  viewportWidth: 0,
1740
1804
  viewportHeight: 0,
1741
1805
  historyBufferSize: 1000,
1742
- touchCount: 0,
1743
1806
  longTouchTimeout: null,
1744
1807
  longTouchDelay: 300,
1808
+ pointers: new Map()
1745
1809
  };
1810
+
1746
1811
  class KritzelStore {
1747
1812
  get history() {
1748
1813
  return this._history;
@@ -1768,7 +1833,7 @@ class KritzelStore {
1768
1833
  constructor(kritzelEngine) {
1769
1834
  this._listeners = new Map();
1770
1835
  this.objects = [];
1771
- this._state = initialState;
1836
+ this._state = DEFAULT_ENGINE_STATE;
1772
1837
  this._kritzelEngine = kritzelEngine;
1773
1838
  this._history = new KritzelHistory(this);
1774
1839
  this._state.objectsOctree = new KritzelOctree({
@@ -2072,46 +2137,6 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
2072
2137
  this.objectContextMenuItems = objectContextMenuItems;
2073
2138
  }
2074
2139
  handleContextMenu(event) {
2075
- if (event.cancelable) {
2076
- event.preventDefault();
2077
- }
2078
- if (!(this._store.state.activeTool instanceof KritzelSelectionTool)) {
2079
- return;
2080
- }
2081
- if (this._store.state.skipContextMenu) {
2082
- this._store.state.skipContextMenu = false;
2083
- return;
2084
- }
2085
- this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
2086
- let x = event.clientX - this._store.offsetX;
2087
- let y = event.clientY - this._store.offsetY;
2088
- const menuWidthEstimate = 150;
2089
- const menuHeightEstimate = 200;
2090
- const margin = 10;
2091
- if (x + menuWidthEstimate > window.innerWidth - margin) {
2092
- x = window.innerWidth - menuWidthEstimate - margin;
2093
- }
2094
- if (y + menuHeightEstimate > window.innerHeight - margin) {
2095
- y = window.innerHeight - menuHeightEstimate - margin;
2096
- }
2097
- x = Math.max(margin, x);
2098
- y = Math.max(margin, y);
2099
- this._store.state.contextMenuX = x;
2100
- this._store.state.contextMenuY = y;
2101
- this._store.state.isContextMenuVisible = true;
2102
- this._store.state.isEnabled = false;
2103
- this._store.rerender();
2104
- }
2105
- handleContextMenuTouch(event) {
2106
- if (event.cancelable) {
2107
- event.preventDefault();
2108
- }
2109
- if (this._store.state.touchCount > 1 || !(this._store.state.activeTool instanceof KritzelSelectionTool)) {
2110
- return;
2111
- }
2112
- if ('vibrate' in navigator) {
2113
- navigator.vibrate(25);
2114
- }
2115
2140
  const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
2116
2141
  if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
2117
2142
  this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
@@ -2122,12 +2147,8 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
2122
2147
  this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
2123
2148
  }
2124
2149
  this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
2125
- const firstTouch = event.touches[0];
2126
- if (!firstTouch) {
2127
- return;
2128
- }
2129
- let x = Math.round(firstTouch.clientX - this._store.offsetX);
2130
- let y = Math.round(firstTouch.clientY - this._store.offsetY);
2150
+ let x = event.clientX - this._store.offsetX;
2151
+ let y = event.clientY - this._store.offsetY;
2131
2152
  const menuWidthEstimate = 150;
2132
2153
  const menuHeightEstimate = 200;
2133
2154
  const margin = 10;
@@ -2147,7 +2168,7 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
2147
2168
  }
2148
2169
  }
2149
2170
 
2150
- const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
2171
+ const kritzelEngineCss = ":host{display:block;position:relative;height:100%;width:100%;overflow:hidden;background-color:var(--kritzel-engine-background-color, #ffffff)}:host,:host *{touch-action:none;user-select:none}.debug-panel{position:absolute;pointer-events:none;top:0;right:0}.origin{position:relative;top:0;left:0;height:0;width:0;pointer-events:none;-webkit-transform-origin:top left;-moz-transform-origin:top left;transform-origin:top left;overflow:visible}.object{overflow:visible}textarea{all:unset;box-sizing:border-box;outline:none !important;border:none !important;overflow:visible}.resize-handle-overlay.top-left,.resize-handle-overlay.bottom-right{cursor:nwse-resize}.resize-handle-overlay.top-right,.resize-handle-overlay.bottom-left{cursor:nesw-resize}.rotation-handle-overlay{cursor:grab}";
2151
2172
 
2152
2173
  const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine extends H {
2153
2174
  get isSelecting() {
@@ -2214,75 +2235,50 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2214
2235
  this.viewport = new KritzelViewport(this.store, this.host);
2215
2236
  this.engineReady.emit();
2216
2237
  }
2217
- handleContextMenu(ev) {
2218
- if (this.store.state.isEnabled === false) {
2219
- return;
2220
- }
2221
- this.contextMenuHandler.handleContextMenu(ev);
2222
- }
2223
- handleMouseDown(ev) {
2238
+ handleWheel(ev) {
2224
2239
  var _a, _b;
2225
2240
  if (this.store.state.isContextMenuVisible) {
2226
2241
  this.hideContextMenu();
2227
- return;
2228
- }
2229
- if (this.store.state.isEnabled === false) {
2230
- return;
2231
- }
2232
- this.viewport.handleMouseDown(ev);
2233
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseDown(ev);
2234
- }
2235
- handleMouseMove(ev) {
2236
- var _a, _b;
2237
- if (this.store.state.isEnabled === false) {
2238
- return;
2239
2242
  }
2240
- this.viewport.handleMouseMove(ev);
2241
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseMove(ev);
2243
+ this.viewport.handleWheel(ev);
2244
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
2242
2245
  }
2243
- handleMouseUp(ev) {
2246
+ handlePointerDown(ev) {
2244
2247
  var _a, _b;
2245
- if (this.store.state.isEnabled === false) {
2248
+ if (KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
2249
+ this.hideContextMenu();
2246
2250
  return;
2247
2251
  }
2248
- this.viewport.handleMouseUp(ev);
2249
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseUp(ev);
2250
- }
2251
- handleDoubleClick(ev) {
2252
- var _a, _b;
2253
2252
  if (this.store.state.isEnabled === false) {
2254
2253
  return;
2255
2254
  }
2256
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleClick(ev);
2257
- }
2258
- handleDoubleTap(ev) {
2259
- var _a, _b;
2260
- if (this.store.state.isEnabled === false) {
2261
- return;
2255
+ if (ev.cancelable) {
2256
+ ev.preventDefault();
2262
2257
  }
2263
- const touchEvent = ev instanceof CustomEvent && ev.detail ? ev.detail : ev;
2264
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleDoubleTap(touchEvent);
2258
+ KritzelEventHelper.onLongTouchPress(ev, (event) => {
2259
+ if (!(this.store.state.activeTool instanceof KritzelSelectionTool)) {
2260
+ return;
2261
+ }
2262
+ this.contextMenuHandler.handleContextMenu(event);
2263
+ });
2264
+ this.host.setPointerCapture(ev.pointerId);
2265
+ this.store.state.pointers.set(ev.pointerId, ev);
2266
+ this.viewport.handlePointerDown(ev);
2267
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerDown(ev);
2265
2268
  }
2266
- handleTouchStart(ev) {
2269
+ handlePointerMove(ev) {
2267
2270
  var _a, _b;
2268
2271
  if (this.store.state.isEnabled === false) {
2269
2272
  return;
2270
2273
  }
2271
- if (KritzelEventHelper.detectDoubleTap()) {
2272
- const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
2273
- this.host.dispatchEvent(doubleTapEvent);
2274
- }
2275
- if (ev.touches.length > 1) {
2276
- clearTimeout(this.store.state.longTouchTimeout);
2277
- }
2278
2274
  if (ev.cancelable) {
2279
2275
  ev.preventDefault();
2280
2276
  }
2281
- this.store.state.longTouchTimeout = setTimeout(() => this.contextMenuHandler.handleContextMenuTouch(ev), this.store.state.longTouchDelay);
2282
- this.viewport.handleTouchStart(ev);
2283
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchStart(ev);
2277
+ this.store.state.pointers.set(ev.pointerId, ev);
2278
+ this.viewport.handlePointerMove(ev);
2279
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerMove(ev);
2284
2280
  }
2285
- handleTouchMove(ev) {
2281
+ handlePointerUp(ev) {
2286
2282
  var _a, _b;
2287
2283
  if (this.store.state.isEnabled === false) {
2288
2284
  return;
@@ -2290,10 +2286,12 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2290
2286
  if (ev.cancelable) {
2291
2287
  ev.preventDefault();
2292
2288
  }
2293
- this.viewport.handleTouchMove(ev);
2294
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchMove(ev);
2289
+ this.store.state.pointers.delete(ev.pointerId);
2290
+ this.host.releasePointerCapture(ev.pointerId);
2291
+ this.viewport.handlePointerUp(ev);
2292
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
2295
2293
  }
2296
- handleTouchEnd(ev) {
2294
+ handlePointerCancel(ev) {
2297
2295
  var _a, _b;
2298
2296
  if (this.store.state.isEnabled === false) {
2299
2297
  return;
@@ -2301,20 +2299,20 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2301
2299
  if (ev.cancelable) {
2302
2300
  ev.preventDefault();
2303
2301
  }
2304
- clearTimeout(this.store.state.longTouchTimeout);
2305
- this.viewport.handleTouchEnd(ev);
2306
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleTouchEnd(ev);
2307
- }
2308
- handleTouchCancel(_ev) {
2309
- clearTimeout(this.store.state.longTouchTimeout);
2302
+ this.host.releasePointerCapture(ev.pointerId);
2303
+ this.store.state.pointers.delete(ev.pointerId);
2304
+ this.viewport.handlePointerUp(ev);
2305
+ (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handlePointerUp(ev);
2310
2306
  }
2311
- handleWheel(ev) {
2312
- var _a, _b;
2313
- if (this.store.state.isContextMenuVisible) {
2314
- this.hideContextMenu();
2307
+ handleContextMenu(ev) {
2308
+ ev.preventDefault();
2309
+ if (this.store.state.isEnabled === false) {
2310
+ return;
2315
2311
  }
2316
- this.viewport.handleWheel(ev);
2317
- (_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleWheel(ev);
2312
+ if (ev.pointerType === 'touch') {
2313
+ return;
2314
+ }
2315
+ this.contextMenuHandler.handleContextMenu(ev);
2318
2316
  }
2319
2317
  handleResize() {
2320
2318
  this.viewport.handleResize();
@@ -2391,6 +2389,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2391
2389
  this.store.history.redo();
2392
2390
  }
2393
2391
  async hideContextMenu() {
2392
+ this.store.state.pointers.clear();
2394
2393
  this.store.state.isContextMenuVisible = false;
2395
2394
  this.store.state.selectionBox = null;
2396
2395
  this.store.state.isSelecting = false;
@@ -2443,20 +2442,20 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2443
2442
  const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
2444
2443
  const baseHandleSize = parseFloat(baseHandleSizePx);
2445
2444
  const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
2446
- return (h(Host, { key: '0c20c50e3ad8ac088902881c35c406ad2f0787d5' }, h("div", { key: 'a89d76b5f6a10cbc54c40d034a08b3ceb99be063', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '94345439d02de7d005bb92abb377b7ebeb91fcdb' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
2447
- _a.translateX), h("div", { key: '1e2e3ffc6ad760f089f4d02d94dfeb09bb5725cb' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
2448
- _b.translateY), h("div", { key: '36d6170934959e19b95326d84b32c9abe2385edc' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
2449
- _c.viewportWidth), h("div", { key: '57e5d37af3fd1f6ad24ea89ca525a6f0bc8e014b' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
2450
- _d.viewportHeight), h("div", { key: '8281e788e350db75bbf1fe12dd8c17b91b429135' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '9f42aad27d0a266cbc720d1e13292bea5be84770' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
2451
- _e.scale), h("div", { key: '76848c1a0eb2379ee0d0314523a540dbeb3d0697' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
2452
- _g.name), h("div", { key: '77f8ff0b660227f7b25c12b74d70946bc1f66e78' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: '229e94fee90a847a853419ae61bc131221313fc6' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: 'f31784916ab54f9a5eda02cffebe55a1f9aaa51f' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '4611a6dd48f1033d42fc3b7813634cbc16bf9b3b' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: '14388f4b5cca60d8a2d8d474f941b53a78ad327d' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '2f3dcd488855413e392f56718af640e369d99fae' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: '2cd0e44a1d13eaf5d3a942f75a727a074bf37622' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: '99d51cf25e02c9d06865bf1f847c704ad8a32110' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '87ab9908a318b238ad1fb00e91dba9c485038443' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: '20f291bf45ba06b4107002e288b93f8f61ef9520' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '52244f4f0d368e7bc183eed4c65abe536d134f44' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: '641edd47e7bccc7514ed6aeac3ecbead95568dde' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
2453
- _m.cursorX), h("div", { key: 'bf0826a9cbc800ca0f13d4de4da7dbb21241498f' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
2454
- _o.cursorY)), h("div", { key: '5659cb254f57b79ca8e33ab11a8087d5ca5088dc', class: "origin", style: {
2445
+ return (h(Host, { key: 'a797514d787c08c2cd6a2e526ace31fecddf8956' }, h("div", { key: 'd0d23c34809f26ab3c21f756923d1ef7a00ebb41', class: "debug-panel", style: { display: this.store.state.debugInfo.showViewportInfo ? 'block' : 'none' } }, h("div", { key: '302b23a9028483c7dc31f4ca983c8036f6de5b25' }, "TranslateX: ", (_a = this.store.state) === null || _a === void 0 ? void 0 :
2446
+ _a.translateX), h("div", { key: '2224e2bb5bd1feea8a65ac4f082342a40e8e18b5' }, "TranslateY: ", (_b = this.store.state) === null || _b === void 0 ? void 0 :
2447
+ _b.translateY), h("div", { key: '02108ee26500eb97a08d8460b6b71cdc553d6c90' }, "ViewportWidth: ", (_c = this.store.state) === null || _c === void 0 ? void 0 :
2448
+ _c.viewportWidth), h("div", { key: '8e87161155f4e2960985292be3101e9f57893381' }, "ViewportHeight: ", (_d = this.store.state) === null || _d === void 0 ? void 0 :
2449
+ _d.viewportHeight), h("div", { key: 'aa2469bda052787a93ea615451676dba4b4fb53e' }, "ObjectsInViewport. ", this.store.objects.length), h("div", { key: '593aaf98bfaec8aae03bd7a3f37e46e14f454333' }, "Scale: ", (_e = this.store.state) === null || _e === void 0 ? void 0 :
2450
+ _e.scale), h("div", { key: '6c9799e82d30236c6f1277830dec32358bfccd93' }, "ActiveTool: ", (_g = (_f = this.store.state) === null || _f === void 0 ? void 0 : _f.activeTool) === null || _g === void 0 ? void 0 :
2451
+ _g.name), h("div", { key: '3dbbec42f8a699a97ef65b5da35f2611866797e5' }, "HasViewportChanged: ", ((_h = this.store.state) === null || _h === void 0 ? void 0 : _h.hasViewportChanged) ? 'true' : 'false'), h("div", { key: '03a71e1efab2801e77e0d8dffc7a4814469613c7' }, "IsEnabled: ", ((_j = this.store.state) === null || _j === void 0 ? void 0 : _j.isEnabled) ? 'true' : 'false'), h("div", { key: '7663ed6cad2ed3b9b74bad5cb238a4cf0310e9e1' }, "IsScaling: ", ((_k = this.store.state) === null || _k === void 0 ? void 0 : _k.isScaling) ? 'true' : 'false'), h("div", { key: '957a1b0906ad9cecc46f470db1ad402d19f94d22' }, "IsPanning: ", ((_l = this.store.state) === null || _l === void 0 ? void 0 : _l.isPanning) ? 'true' : 'false'), h("div", { key: 'b73277742d0966445b6f49a0fb1433f80cab1d60' }, "IsFocused: ", this.store.state.isFocused ? 'true' : 'false'), h("div", { key: '6a4e0ca6d868b1f8ccfe2957f352fc454b3527ea' }, "IsSelecting: ", this.isSelecting ? 'true' : 'false'), h("div", { key: 'da9dce9f4c38cd740f27ecc8de3c32edac2a7fe2' }, "IsSelectionActive: ", this.isSelectionActive ? 'true' : 'false'), h("div", { key: 'f6b0d7cc9e828cac5a65879b9973944a444be6b1' }, "IsResizeHandleSelected: ", this.store.state.isResizeHandleSelected ? 'true' : 'false'), h("div", { key: '3ef7c46329e47a97703e49f47c8f5325f0d4b9b2' }, "IsRotationHandleSelected: ", this.store.state.isRotationHandleSelected ? 'true' : 'false'), h("div", { key: 'cab4fb21ede0b4f4925e9d7d2175ad8661f07907' }, "IsDrawing: ", this.store.state.isDrawing ? 'true' : 'false'), h("div", { key: '2f4eeaa711a56e2246495fe1eee46d5629c93364' }, "IsWriting: ", this.store.state.isWriting ? 'true' : 'false'), h("div", { key: 'ee2e5edcd140da8b957b468989c71e7c247063bb' }, "CursorX: ", (_m = this.store.state) === null || _m === void 0 ? void 0 :
2452
+ _m.cursorX), h("div", { key: '1fea9888ca2f1a9fed25ad0cac065d8278c78227' }, "CursorY: ", (_o = this.store.state) === null || _o === void 0 ? void 0 :
2453
+ _o.cursorY)), h("div", { key: '226c675711317ff06f1db5165fa19794310f2e1e', class: "origin", style: {
2455
2454
  transform: `matrix(${(_p = this.store.state) === null || _p === void 0 ? void 0 : _p.scale}, 0, 0, ${(_q = this.store.state) === null || _q === void 0 ? void 0 : _q.scale}, ${(_r = this.store.state) === null || _r === void 0 ? void 0 : _r.translateX}, ${(_s = this.store.state) === null || _s === void 0 ? void 0 : _s.translateY})`,
2456
2455
  } }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
2457
2456
  _t.map(object => {
2458
2457
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
2459
- return (h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
2458
+ return (h("div", { style: { transform: object === null || object === void 0 ? void 0 : object.transformationMatrix, transformOrigin: 'top left', zIndex: object.zIndex.toString(), position: 'absolute' } }, h("svg", { xmlns: "http://www.w3.org/2000/svg", key: object.id, id: object.id, class: "object", style: {
2460
2459
  height: object === null || object === void 0 ? void 0 : object.totalHeight.toString(),
2461
2460
  width: object === null || object === void 0 ? void 0 : object.totalWidth.toString(),
2462
2461
  left: '0',
@@ -2466,7 +2465,6 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2466
2465
  transformOrigin: 'center',
2467
2466
  opacity: object.markedForRemoval ? '0.5' : object.opacity.toString(),
2468
2467
  pointerEvents: object.markedForRemoval ? 'none' : 'auto',
2469
- zIndex: object.zIndex.toString(),
2470
2468
  } }, h("foreignObject", { x: "0", y: "0", width: object.totalWidth.toString(), height: object.totalHeight.toString(), style: {
2471
2469
  minHeight: '0',
2472
2470
  minWidth: '0',
@@ -2499,6 +2497,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2499
2497
  display: 'block',
2500
2498
  padding: '1px',
2501
2499
  whiteSpace: 'nowrap',
2500
+ pointerEvents: object.isReadonly ? 'none' : 'auto',
2502
2501
  cursor: object.isReadonly ? 'default' : 'text',
2503
2502
  caretColor: object.isReadonly ? 'transparent' : 'auto',
2504
2503
  } })), object instanceof KritzelSelectionGroup && (h("div", { ref: el => object.mount(el), style: {
@@ -2548,7 +2547,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2548
2547
  fill: 'transparent',
2549
2548
  cursor: 'grab',
2550
2549
  }, visibility: object.selected && !this.isSelecting ? 'visible' : 'hidden' }), h("g", { style: { display: this.store.state.debugInfo.showObjectInfo ? 'block' : 'none', pointerEvents: 'none' } }, h("foreignObject", { x: object.totalWidth.toString(), y: "0", width: "400px", height: "160px", style: { minHeight: '0', minWidth: '0', display: object.debugInfoVisible ? 'block' : 'none' } }, h("div", { style: { width: '100%', height: '100%' } }, h("div", { style: { whiteSpace: 'nowrap' } }, "zIndex: ", object.zIndex), h("div", { style: { whiteSpace: 'nowrap' } }, "translateX: ", object.translateX), h("div", { style: { whiteSpace: 'nowrap' } }, "translateY: ", object.translateY), h("div", { style: { whiteSpace: 'nowrap' } }, "width: ", object.width), h("div", { style: { whiteSpace: 'nowrap' } }, "height: ", object.height), h("div", { style: { whiteSpace: 'nowrap' } }, "scale: ", object.scale), h("div", { style: { whiteSpace: 'nowrap' } }, "rotation: ", object.rotation)))))));
2551
- }), h("svg", { key: '05a35ebb17312d00a4065dc6dc76f3a93a72eff4', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
2550
+ }), h("svg", { key: '34f891f9408d3b0174c67b869f49cce7329fd84a', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
2552
2551
  height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
2553
2552
  width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
2554
2553
  left: '0',
@@ -2558,12 +2557,12 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2558
2557
  transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
2559
2558
  transformOrigin: 'top left',
2560
2559
  overflow: 'visible',
2561
- }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: 'cb232e2697ce6ede2e4d9ed2e1b433ccde3961b5', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: 'e41b88a78bbd25f692fbdba88fda80993055a078', ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
2560
+ }, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '97360b7270a285a87a45459e497968a444cc83cb', d: (_z = this.store.state.currentPath) === null || _z === void 0 ? void 0 : _z.d, fill: (_0 = this.store.state.currentPath) === null || _0 === void 0 ? void 0 : _0.fill, stroke: (_1 = this.store.state.currentPath) === null || _1 === void 0 ? void 0 : _1.stroke }))), this.store.state.isContextMenuVisible && (h("kritzel-context-menu", { key: '111d7b1daccd69aaf914dfcd51f525f2ad81802e', class: "context-menu", ref: el => (this.contextMenuElement = el), items: this.store.state.contextMenuItems, style: {
2562
2561
  position: 'fixed',
2563
2562
  left: `${this.store.state.contextMenuX}px`,
2564
2563
  top: `${this.store.state.contextMenuY}px`,
2565
2564
  zIndex: '10000',
2566
- }, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '1d96c0d7fa94ddcf5820fd76fbaf69c54b1face2' })));
2565
+ }, onActionSelected: event => this.handleContextMenuAction(event) })), ((_2 = this.store.state) === null || _2 === void 0 ? void 0 : _2.activeTool) instanceof KritzelEraserTool && !this.store.state.isScaling && h("kritzel-cursor-trail", { key: '9814ec7d95a84edc8af1bff319eff5f59b8cfc86' })));
2567
2566
  }
2568
2567
  get host() { return this; }
2569
2568
  static get style() { return kritzelEngineCss; }
@@ -2592,7 +2591,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
2592
2591
  "selectObjects": [64],
2593
2592
  "selectAllObjectsInViewport": [64],
2594
2593
  "clearSelection": [64]
2595
- }, [[0, "contextmenu", "handleContextMenu"], [1, "mousedown", "handleMouseDown"], [1, "mousemove", "handleMouseMove"], [1, "mouseup", "handleMouseUp"], [0, "dblclick", "handleDoubleClick"], [0, "doubletap", "handleDoubleTap"], [0, "touchstart", "handleTouchStart"], [0, "touchmove", "handleTouchMove"], [0, "touchend", "handleTouchEnd"], [0, "touchcancel", "handleTouchCancel"], [0, "wheel", "handleWheel"], [9, "resize", "handleResize"], [8, "keydown", "handleKeyDown"], [8, "keyup", "handleKeyUp"], [9, "mousedown", "updateFocus"]]]);
2594
+ }, [[0, "wheel", "handleWheel"], [0, "pointerdown", "handlePointerDown"], [0, "pointermove", "handlePointerMove"], [0, "pointerup", "handlePointerUp"], [0, "pointercancel", "handlePointerCancel"], [0, "contextmenu", "handleContextMenu"], [9, "resize", "handleResize"], [8, "keydown", "handleKeyDown"], [8, "keyup", "handleKeyUp"], [9, "mousedown", "updateFocus"]]]);
2596
2595
  function defineCustomElement() {
2597
2596
  if (typeof customElements === "undefined") {
2598
2597
  return;
@@ -2623,6 +2622,6 @@ function defineCustomElement() {
2623
2622
  }
2624
2623
 
2625
2624
  export { KritzelEngine as K, KritzelSelectionTool as a, KritzelEraserTool as b, KritzelImageTool as c, defineCustomElement as d };
2626
- //# sourceMappingURL=p-_3gCPfqz.js.map
2625
+ //# sourceMappingURL=p-BmrZipyu.js.map
2627
2626
 
2628
- //# sourceMappingURL=p-_3gCPfqz.js.map
2627
+ //# sourceMappingURL=p-BmrZipyu.js.map