kritzel-stencil 0.0.108 → 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.
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +853 -832
- package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +2 -47
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +62 -55
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +122 -113
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +74 -66
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +59 -50
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +3 -0
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +11 -1
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/tools/base-tool.class.js +3 -18
- package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +79 -71
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +93 -73
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +73 -70
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/classes/viewport.class.js +76 -69
- package/dist/collection/classes/viewport.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +66 -120
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +1 -1
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/devices.helper.js +6 -0
- package/dist/collection/helpers/devices.helper.js.map +1 -0
- package/dist/collection/helpers/event.helper.js +43 -34
- package/dist/collection/helpers/event.helper.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/object.interface.js.map +1 -1
- package/dist/collection/interfaces/tool.interface.js.map +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +5 -5
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-BNfHRlWL.js → p-7Ns73-wN.js} +237 -220
- package/dist/components/p-7Ns73-wN.js.map +1 -0
- package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
- package/dist/components/p-BmAloSfd.js.map +1 -0
- package/dist/components/{p-CqJr3YCp.js → p-BmrZipyu.js} +617 -621
- package/dist/components/p-BmrZipyu.js.map +1 -0
- package/dist/components/{p-Box62paJ.js → p-Ch6TgHX3.js} +18 -8
- package/dist/components/p-Ch6TgHX3.js.map +1 -0
- package/dist/esm/kritzel-brush-style_18.entry.js +853 -832
- package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/p-c976660c.entry.js +2 -0
- package/dist/stencil/p-c976660c.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
- package/dist/types/classes/handlers/move.handler.d.ts +3 -6
- package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
- package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
- package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
- package/dist/types/classes/objects/base-object.class.d.ts +1 -0
- package/dist/types/classes/objects/text.class.d.ts +1 -0
- package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
- package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
- package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
- package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
- package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
- package/dist/types/classes/viewport.class.d.ts +3 -6
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
- package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
- package/dist/types/components.d.ts +0 -2
- package/dist/types/helpers/devices.helper.d.ts +3 -0
- package/dist/types/helpers/event.helper.d.ts +2 -6
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
- package/dist/types/interfaces/object.interface.d.ts +1 -0
- package/dist/types/interfaces/tool.interface.d.ts +3 -8
- package/package.json +1 -1
- package/dist/components/p-BNfHRlWL.js.map +0 -1
- package/dist/components/p-Box62paJ.js.map +0 -1
- package/dist/components/p-Cbu5RSmC.js.map +0 -1
- package/dist/components/p-CqJr3YCp.js.map +0 -1
- package/dist/stencil/p-3a7d7b58.entry.js +0 -2
- package/dist/stencil/p-3a7d7b58.entry.js.map +0 -1
|
@@ -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-
|
|
3
|
-
import { K as KritzelContextMenu, d as defineCustomElement$3 } from './p-
|
|
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
|
-
|
|
39
|
-
if (
|
|
40
|
-
|
|
38
|
+
handlePointerDown(event) {
|
|
39
|
+
if (event.pointerType === 'mouse') {
|
|
40
|
+
if (KritzelEventHelper.isLeftClick(event)) {
|
|
41
|
+
this._store.state.isErasing = true;
|
|
42
|
+
}
|
|
41
43
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
|
|
190
|
-
var _a;
|
|
191
|
-
if (
|
|
192
|
-
if ((
|
|
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.
|
|
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
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
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
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
293
|
-
if (
|
|
294
|
-
if (
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
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
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
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 (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
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 (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
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
|
-
|
|
451
|
-
if (
|
|
452
|
-
if (
|
|
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.
|
|
456
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
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.
|
|
496
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
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
|
-
|
|
639
|
-
if (
|
|
640
|
-
|
|
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
|
-
|
|
644
|
-
|
|
645
|
-
|
|
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
|
-
|
|
649
|
-
if (
|
|
650
|
-
if (this.
|
|
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
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
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
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
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
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
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(
|
|
719
|
-
const
|
|
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(
|
|
756
|
-
const
|
|
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
|
-
|
|
823
|
-
if (
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
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
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
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
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
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
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
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
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
this._store.
|
|
1343
|
-
this._store.state.
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
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
|
-
|
|
1355
|
-
if (
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
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
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
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)) {
|
|
@@ -1739,9 +1803,9 @@ const DEFAULT_ENGINE_STATE = {
|
|
|
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
|
};
|
|
1746
1810
|
|
|
1747
1811
|
class KritzelStore {
|
|
@@ -2073,46 +2137,6 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
2073
2137
|
this.objectContextMenuItems = objectContextMenuItems;
|
|
2074
2138
|
}
|
|
2075
2139
|
handleContextMenu(event) {
|
|
2076
|
-
if (event.cancelable) {
|
|
2077
|
-
event.preventDefault();
|
|
2078
|
-
}
|
|
2079
|
-
if (!(this._store.state.activeTool instanceof KritzelSelectionTool)) {
|
|
2080
|
-
return;
|
|
2081
|
-
}
|
|
2082
|
-
if (this._store.state.skipContextMenu) {
|
|
2083
|
-
this._store.state.skipContextMenu = false;
|
|
2084
|
-
return;
|
|
2085
|
-
}
|
|
2086
|
-
this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
2087
|
-
let x = event.clientX - this._store.offsetX;
|
|
2088
|
-
let y = event.clientY - this._store.offsetY;
|
|
2089
|
-
const menuWidthEstimate = 150;
|
|
2090
|
-
const menuHeightEstimate = 200;
|
|
2091
|
-
const margin = 10;
|
|
2092
|
-
if (x + menuWidthEstimate > window.innerWidth - margin) {
|
|
2093
|
-
x = window.innerWidth - menuWidthEstimate - margin;
|
|
2094
|
-
}
|
|
2095
|
-
if (y + menuHeightEstimate > window.innerHeight - margin) {
|
|
2096
|
-
y = window.innerHeight - menuHeightEstimate - margin;
|
|
2097
|
-
}
|
|
2098
|
-
x = Math.max(margin, x);
|
|
2099
|
-
y = Math.max(margin, y);
|
|
2100
|
-
this._store.state.contextMenuX = x;
|
|
2101
|
-
this._store.state.contextMenuY = y;
|
|
2102
|
-
this._store.state.isContextMenuVisible = true;
|
|
2103
|
-
this._store.state.isEnabled = false;
|
|
2104
|
-
this._store.rerender();
|
|
2105
|
-
}
|
|
2106
|
-
handleContextMenuTouch(event) {
|
|
2107
|
-
if (event.cancelable) {
|
|
2108
|
-
event.preventDefault();
|
|
2109
|
-
}
|
|
2110
|
-
if (this._store.state.touchCount > 1 || !(this._store.state.activeTool instanceof KritzelSelectionTool)) {
|
|
2111
|
-
return;
|
|
2112
|
-
}
|
|
2113
|
-
if ('vibrate' in navigator) {
|
|
2114
|
-
navigator.vibrate(25);
|
|
2115
|
-
}
|
|
2116
2140
|
const selectedObject = this._store.getObjectFromPointerEvent(event, '.object');
|
|
2117
2141
|
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
|
|
2118
2142
|
this._store.state.selectionGroup = KritzelSelectionGroup.create(this._store);
|
|
@@ -2123,12 +2147,8 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
2123
2147
|
this._store.history.executeCommand(new AddSelectionGroupCommand(this._store, this, this._store.state.selectionGroup));
|
|
2124
2148
|
}
|
|
2125
2149
|
this._store.state.contextMenuItems = this._store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
return;
|
|
2129
|
-
}
|
|
2130
|
-
let x = Math.round(firstTouch.clientX - this._store.offsetX);
|
|
2131
|
-
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;
|
|
2132
2152
|
const menuWidthEstimate = 150;
|
|
2133
2153
|
const menuHeightEstimate = 200;
|
|
2134
2154
|
const margin = 10;
|
|
@@ -2148,7 +2168,7 @@ class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
2148
2168
|
}
|
|
2149
2169
|
}
|
|
2150
2170
|
|
|
2151
|
-
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}";
|
|
2152
2172
|
|
|
2153
2173
|
const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine extends H {
|
|
2154
2174
|
get isSelecting() {
|
|
@@ -2215,78 +2235,50 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2215
2235
|
this.viewport = new KritzelViewport(this.store, this.host);
|
|
2216
2236
|
this.engineReady.emit();
|
|
2217
2237
|
}
|
|
2218
|
-
|
|
2219
|
-
if (this.store.state.isEnabled === false) {
|
|
2220
|
-
return;
|
|
2221
|
-
}
|
|
2222
|
-
this.contextMenuHandler.handleContextMenu(ev);
|
|
2223
|
-
}
|
|
2224
|
-
handleMouseDown(ev) {
|
|
2238
|
+
handleWheel(ev) {
|
|
2225
2239
|
var _a, _b;
|
|
2226
2240
|
if (this.store.state.isContextMenuVisible) {
|
|
2227
2241
|
this.hideContextMenu();
|
|
2228
|
-
return;
|
|
2229
|
-
}
|
|
2230
|
-
if (this.store.state.isEnabled === false) {
|
|
2231
|
-
return;
|
|
2232
|
-
}
|
|
2233
|
-
this.viewport.handleMouseDown(ev);
|
|
2234
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseDown(ev);
|
|
2235
|
-
}
|
|
2236
|
-
handleMouseMove(ev) {
|
|
2237
|
-
var _a, _b;
|
|
2238
|
-
if (this.store.state.isEnabled === false) {
|
|
2239
|
-
return;
|
|
2240
2242
|
}
|
|
2241
|
-
this.viewport.
|
|
2242
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.
|
|
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);
|
|
2243
2245
|
}
|
|
2244
|
-
|
|
2246
|
+
handlePointerDown(ev) {
|
|
2245
2247
|
var _a, _b;
|
|
2246
|
-
if (this.store.state.
|
|
2248
|
+
if (KritzelEventHelper.isPointerEventOnContextMenu(ev) === false && this.store.state.isContextMenuVisible) {
|
|
2249
|
+
this.hideContextMenu();
|
|
2247
2250
|
return;
|
|
2248
2251
|
}
|
|
2249
|
-
this.viewport.handleMouseUp(ev);
|
|
2250
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.handleMouseUp(ev);
|
|
2251
|
-
}
|
|
2252
|
-
handleDoubleClick(ev) {
|
|
2253
|
-
var _a, _b;
|
|
2254
2252
|
if (this.store.state.isEnabled === false) {
|
|
2255
2253
|
return;
|
|
2256
2254
|
}
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
handleDoubleTap(ev) {
|
|
2260
|
-
var _a, _b;
|
|
2261
|
-
if (this.store.state.isEnabled === false) {
|
|
2262
|
-
return;
|
|
2255
|
+
if (ev.cancelable) {
|
|
2256
|
+
ev.preventDefault();
|
|
2263
2257
|
}
|
|
2264
|
-
|
|
2265
|
-
|
|
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);
|
|
2266
2268
|
}
|
|
2267
|
-
|
|
2269
|
+
handlePointerMove(ev) {
|
|
2268
2270
|
var _a, _b;
|
|
2269
2271
|
if (this.store.state.isEnabled === false) {
|
|
2270
2272
|
return;
|
|
2271
2273
|
}
|
|
2272
|
-
if (ev.touches.length === 2) {
|
|
2273
|
-
KritzelEventHelper.notifyTwoFingerTouch();
|
|
2274
|
-
}
|
|
2275
|
-
if (KritzelEventHelper.detectDoubleTap()) {
|
|
2276
|
-
const doubleTapEvent = new CustomEvent('doubletap', { detail: event, bubbles: true, composed: true });
|
|
2277
|
-
this.host.dispatchEvent(doubleTapEvent);
|
|
2278
|
-
}
|
|
2279
|
-
if (ev.touches.length > 1) {
|
|
2280
|
-
clearTimeout(this.store.state.longTouchTimeout);
|
|
2281
|
-
}
|
|
2282
2274
|
if (ev.cancelable) {
|
|
2283
2275
|
ev.preventDefault();
|
|
2284
2276
|
}
|
|
2285
|
-
this.store.state.
|
|
2286
|
-
this.viewport.
|
|
2287
|
-
(_b = (_a = this.store.state) === null || _a === void 0 ? void 0 : _a.activeTool) === null || _b === void 0 ? void 0 : _b.
|
|
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);
|
|
2288
2280
|
}
|
|
2289
|
-
|
|
2281
|
+
handlePointerUp(ev) {
|
|
2290
2282
|
var _a, _b;
|
|
2291
2283
|
if (this.store.state.isEnabled === false) {
|
|
2292
2284
|
return;
|
|
@@ -2294,10 +2286,12 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2294
2286
|
if (ev.cancelable) {
|
|
2295
2287
|
ev.preventDefault();
|
|
2296
2288
|
}
|
|
2297
|
-
this.
|
|
2298
|
-
|
|
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);
|
|
2299
2293
|
}
|
|
2300
|
-
|
|
2294
|
+
handlePointerCancel(ev) {
|
|
2301
2295
|
var _a, _b;
|
|
2302
2296
|
if (this.store.state.isEnabled === false) {
|
|
2303
2297
|
return;
|
|
@@ -2305,20 +2299,20 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2305
2299
|
if (ev.cancelable) {
|
|
2306
2300
|
ev.preventDefault();
|
|
2307
2301
|
}
|
|
2308
|
-
|
|
2309
|
-
this.
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
handleTouchCancel(_ev) {
|
|
2313
|
-
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);
|
|
2314
2306
|
}
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
if (this.store.state.
|
|
2318
|
-
|
|
2307
|
+
handleContextMenu(ev) {
|
|
2308
|
+
ev.preventDefault();
|
|
2309
|
+
if (this.store.state.isEnabled === false) {
|
|
2310
|
+
return;
|
|
2319
2311
|
}
|
|
2320
|
-
|
|
2321
|
-
|
|
2312
|
+
if (ev.pointerType === 'touch') {
|
|
2313
|
+
return;
|
|
2314
|
+
}
|
|
2315
|
+
this.contextMenuHandler.handleContextMenu(ev);
|
|
2322
2316
|
}
|
|
2323
2317
|
handleResize() {
|
|
2324
2318
|
this.viewport.handleResize();
|
|
@@ -2395,6 +2389,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2395
2389
|
this.store.history.redo();
|
|
2396
2390
|
}
|
|
2397
2391
|
async hideContextMenu() {
|
|
2392
|
+
this.store.state.pointers.clear();
|
|
2398
2393
|
this.store.state.isContextMenuVisible = false;
|
|
2399
2394
|
this.store.state.selectionBox = null;
|
|
2400
2395
|
this.store.state.isSelecting = false;
|
|
@@ -2447,15 +2442,15 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2447
2442
|
const baseHandleSizePx = computedStyle.getPropertyValue('--kritzel-selection-handle-size').trim() || '6px';
|
|
2448
2443
|
const baseHandleSize = parseFloat(baseHandleSizePx);
|
|
2449
2444
|
const baseHandleTouchSize = baseHandleSize * 2 < 14 ? 14 : baseHandleSize;
|
|
2450
|
-
return (h(Host, { key: '
|
|
2451
|
-
_a.translateX), h("div", { key: '
|
|
2452
|
-
_b.translateY), h("div", { key: '
|
|
2453
|
-
_c.viewportWidth), h("div", { key: '
|
|
2454
|
-
_d.viewportHeight), h("div", { key: '
|
|
2455
|
-
_e.scale), h("div", { key: '
|
|
2456
|
-
_g.name), h("div", { key: '
|
|
2457
|
-
_m.cursorX), h("div", { key: '
|
|
2458
|
-
_o.cursorY)), h("div", { key: '
|
|
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: {
|
|
2459
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})`,
|
|
2460
2455
|
} }, (_t = this.store.objects) === null || _t === void 0 ? void 0 :
|
|
2461
2456
|
_t.map(object => {
|
|
@@ -2502,6 +2497,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2502
2497
|
display: 'block',
|
|
2503
2498
|
padding: '1px',
|
|
2504
2499
|
whiteSpace: 'nowrap',
|
|
2500
|
+
pointerEvents: object.isReadonly ? 'none' : 'auto',
|
|
2505
2501
|
cursor: object.isReadonly ? 'default' : 'text',
|
|
2506
2502
|
caretColor: object.isReadonly ? 'transparent' : 'auto',
|
|
2507
2503
|
} })), object instanceof KritzelSelectionGroup && (h("div", { ref: el => object.mount(el), style: {
|
|
@@ -2551,7 +2547,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2551
2547
|
fill: 'transparent',
|
|
2552
2548
|
cursor: 'grab',
|
|
2553
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)))))));
|
|
2554
|
-
}), h("svg", { key: '
|
|
2550
|
+
}), h("svg", { key: '34f891f9408d3b0174c67b869f49cce7329fd84a', class: "object", xmlns: "http://www.w3.org/2000/svg", style: {
|
|
2555
2551
|
height: (_u = this.store.state.currentPath) === null || _u === void 0 ? void 0 : _u.height.toString(),
|
|
2556
2552
|
width: (_v = this.store.state.currentPath) === null || _v === void 0 ? void 0 : _v.width.toString(),
|
|
2557
2553
|
left: '0',
|
|
@@ -2561,12 +2557,12 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2561
2557
|
transform: (_x = this.store.state.currentPath) === null || _x === void 0 ? void 0 : _x.transformationMatrix,
|
|
2562
2558
|
transformOrigin: 'top left',
|
|
2563
2559
|
overflow: 'visible',
|
|
2564
|
-
}, viewBox: (_y = this.store.state.currentPath) === null || _y === void 0 ? void 0 : _y.viewBox }, h("path", { key: '
|
|
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: {
|
|
2565
2561
|
position: 'fixed',
|
|
2566
2562
|
left: `${this.store.state.contextMenuX}px`,
|
|
2567
2563
|
top: `${this.store.state.contextMenuY}px`,
|
|
2568
2564
|
zIndex: '10000',
|
|
2569
|
-
}, 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: '
|
|
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' })));
|
|
2570
2566
|
}
|
|
2571
2567
|
get host() { return this; }
|
|
2572
2568
|
static get style() { return kritzelEngineCss; }
|
|
@@ -2595,7 +2591,7 @@ const KritzelEngine = /*@__PURE__*/ proxyCustomElement(class KritzelEngine exten
|
|
|
2595
2591
|
"selectObjects": [64],
|
|
2596
2592
|
"selectAllObjectsInViewport": [64],
|
|
2597
2593
|
"clearSelection": [64]
|
|
2598
|
-
}, [[0, "
|
|
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"]]]);
|
|
2599
2595
|
function defineCustomElement() {
|
|
2600
2596
|
if (typeof customElements === "undefined") {
|
|
2601
2597
|
return;
|
|
@@ -2626,6 +2622,6 @@ function defineCustomElement() {
|
|
|
2626
2622
|
}
|
|
2627
2623
|
|
|
2628
2624
|
export { KritzelEngine as K, KritzelSelectionTool as a, KritzelEraserTool as b, KritzelImageTool as c, defineCustomElement as d };
|
|
2629
|
-
//# sourceMappingURL=p-
|
|
2625
|
+
//# sourceMappingURL=p-BmrZipyu.js.map
|
|
2630
2626
|
|
|
2631
|
-
//# sourceMappingURL=p-
|
|
2627
|
+
//# sourceMappingURL=p-BmrZipyu.js.map
|