kritzel-stencil 0.0.139 → 0.0.141
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/index-BKstgWru.js +16981 -0
- package/dist/cjs/index-BKstgWru.js.map +1 -0
- package/dist/cjs/{index-nzUNdMPh.js → index-DcTwXs_q.js} +47 -22
- package/dist/cjs/index-DcTwXs_q.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +205 -157
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/stencil.cjs.js +3 -3
- package/dist/cjs/stencil.cjs.js.map +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +4 -4
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +2 -2
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-viewport.command.js +6 -6
- package/dist/collection/classes/commands/update-viewport.command.js.map +1 -1
- package/dist/collection/classes/core/core.class.js +52 -29
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/history.class.js +3 -3
- package/dist/collection/classes/core/history.class.js.map +1 -1
- package/dist/collection/classes/core/store.class.js +4 -1
- package/dist/collection/classes/core/store.class.js.map +1 -1
- package/dist/collection/classes/core/viewport.class.js +63 -44
- package/dist/collection/classes/core/viewport.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +16 -8
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +4 -4
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +30 -8
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +6 -6
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +6 -6
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +56 -28
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +9 -3
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +3 -1
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +123 -75
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +16 -16
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +4 -4
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +7 -7
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +8 -10
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -2
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +5 -9
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -8
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +30 -38
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -2
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +5 -5
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +4 -5
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +5 -6
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +4 -4
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +3 -4
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +3 -4
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +5 -5
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -3
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -4
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -1
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +6 -7
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +5 -6
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +2 -3
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +7 -8
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -3
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +3 -4
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +3 -4
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +4 -6
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +1 -3
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
- package/dist/components/index.js +3 -3
- package/dist/components/kritzel-brush-style.js +4 -4
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +26 -26
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-BlPlPpUy.js → p-BEKicPnH.js} +4 -4
- package/dist/components/{p-BlPlPpUy.js.map → p-BEKicPnH.js.map} +1 -1
- package/dist/components/{p-DCx3703u.js → p-BFNwskCY.js} +5 -5
- package/dist/components/{p-DCx3703u.js.map → p-BFNwskCY.js.map} +1 -1
- package/dist/components/{p-BorT6g39.js → p-BJbN3vca.js} +7 -7
- package/dist/components/{p-BorT6g39.js.map → p-BJbN3vca.js.map} +1 -1
- package/dist/components/p-BuDVaqTF.js +15302 -0
- package/dist/components/p-BuDVaqTF.js.map +1 -0
- package/dist/components/{p-Db3kxVe2.js → p-ByAzDzS5.js} +4 -4
- package/dist/components/{p-Db3kxVe2.js.map → p-ByAzDzS5.js.map} +1 -1
- package/dist/components/{p-sreNwi0N.js → p-BycHaC-9.js} +5 -5
- package/dist/components/{p-sreNwi0N.js.map → p-BycHaC-9.js.map} +1 -1
- package/dist/components/{p-KudVTtHk.js → p-C4nj29RW.js} +310 -210
- package/dist/components/p-C4nj29RW.js.map +1 -0
- package/dist/components/{p-BYanlgdq.js → p-C9hrbrUN.js} +27 -14
- package/dist/components/p-C9hrbrUN.js.map +1 -0
- package/dist/components/{p-BgpsMYcw.js → p-CEn1WeG3.js} +8 -8
- package/dist/components/p-CEn1WeG3.js.map +1 -0
- package/dist/components/{p-BM9IjvnD.js → p-CGb-8cK4.js} +4 -4
- package/dist/components/{p-BM9IjvnD.js.map → p-CGb-8cK4.js.map} +1 -1
- package/dist/components/{p-B7kZ1_RH.js → p-C_hSH2nN.js} +5 -5
- package/dist/components/{p-B7kZ1_RH.js.map → p-C_hSH2nN.js.map} +1 -1
- package/dist/components/{p-CHdJi6b4.js → p-ChLi4Ufe.js} +20 -20
- package/dist/components/{p-CHdJi6b4.js.map → p-ChLi4Ufe.js.map} +1 -1
- package/dist/components/{p-BPsQrpzN.js → p-CieOx1XL.js} +8 -8
- package/dist/components/{p-BPsQrpzN.js.map → p-CieOx1XL.js.map} +1 -1
- package/dist/components/{p-DjU7p3od.js → p-Co5lU_7h.js} +12 -12
- package/dist/components/{p-DjU7p3od.js.map → p-Co5lU_7h.js.map} +1 -1
- package/dist/components/{p-sq9jgfX0.js → p-D27d2rKT.js} +3 -3
- package/dist/components/{p-sq9jgfX0.js.map → p-D27d2rKT.js.map} +1 -1
- package/dist/components/{p-DFO-6kuA.js → p-DPxzgBs0.js} +3 -3
- package/dist/components/{p-DFO-6kuA.js.map → p-DPxzgBs0.js.map} +1 -1
- package/dist/components/{p-0iJh9Z6m.js → p-D_RcVGj0.js} +5 -5
- package/dist/components/{p-0iJh9Z6m.js.map → p-D_RcVGj0.js.map} +1 -1
- package/dist/components/{p-DOPuq6gn.js → p-DqsgZIHC.js} +5 -5
- package/dist/components/{p-DOPuq6gn.js.map → p-DqsgZIHC.js.map} +1 -1
- package/dist/components/{p-BehchtaT.js → p-DzyZA2GT.js} +8 -8
- package/dist/components/{p-BehchtaT.js.map → p-DzyZA2GT.js.map} +1 -1
- package/dist/components/{p-Ddlbt3Bj.js → p-dcR2uxM3.js} +6 -6
- package/dist/components/{p-Ddlbt3Bj.js.map → p-dcR2uxM3.js.map} +1 -1
- package/dist/components/{p-B7w19kIk.js → p-fiFoOjv0.js} +9 -9
- package/dist/components/{p-B7w19kIk.js.map → p-fiFoOjv0.js.map} +1 -1
- package/dist/components/{p-CsyM5q2M.js → p-gCHmJzc2.js} +5 -5
- package/dist/components/{p-CsyM5q2M.js.map → p-gCHmJzc2.js.map} +1 -1
- package/dist/esm/{index-oCOlsFCN.js → index-Cw77zP6g.js} +47 -22
- package/dist/esm/index-Cw77zP6g.js.map +1 -0
- package/dist/esm/index-D0Q2MKPn.js +16953 -0
- package/dist/esm/index-D0Q2MKPn.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style.entry.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +205 -157
- package/dist/esm/loader.js +3 -3
- package/dist/esm/stencil.js +4 -4
- package/dist/esm/stencil.js.map +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-73784709.entry.js +2 -0
- package/dist/stencil/p-73784709.entry.js.map +1 -0
- package/dist/stencil/{p-25d1e040.entry.js → p-8b831c94.entry.js} +2 -2
- package/dist/stencil/p-Cw77zP6g.js +3 -0
- package/dist/stencil/p-Cw77zP6g.js.map +1 -0
- package/dist/stencil/p-D0Q2MKPn.js +2 -0
- package/dist/stencil/p-D0Q2MKPn.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/stencil/stencil.esm.js.map +1 -1
- package/dist/types/classes/core/store.class.d.ts +2 -1
- package/dist/types/classes/core/viewport.class.d.ts +3 -0
- package/dist/types/classes/handlers/move.handler.d.ts +2 -0
- package/dist/types/classes/handlers/selection.handler.d.ts +3 -0
- package/dist/types/classes/objects/text.class.d.ts +20 -10
- package/dist/types/stencil-public-runtime.d.ts +36 -12
- package/package.json +7 -2
- package/dist/cjs/index-DgZMn9B_.js +0 -2791
- package/dist/cjs/index-DgZMn9B_.js.map +0 -1
- package/dist/cjs/index-nzUNdMPh.js.map +0 -1
- package/dist/components/p-BYanlgdq.js.map +0 -1
- package/dist/components/p-BbGgijCS.js +0 -1164
- package/dist/components/p-BbGgijCS.js.map +0 -1
- package/dist/components/p-BgpsMYcw.js.map +0 -1
- package/dist/components/p-KudVTtHk.js.map +0 -1
- package/dist/esm/index-CxieEK_G.js +0 -2763
- package/dist/esm/index-CxieEK_G.js.map +0 -1
- package/dist/esm/index-oCOlsFCN.js.map +0 -1
- package/dist/stencil/p-CxieEK_G.js +0 -2
- package/dist/stencil/p-CxieEK_G.js.map +0 -1
- package/dist/stencil/p-ab074e87.entry.js +0 -2
- package/dist/stencil/p-ab074e87.entry.js.map +0 -1
- package/dist/stencil/p-oCOlsFCN.js +0 -3
- package/dist/stencil/p-oCOlsFCN.js.map +0 -1
- /package/dist/stencil/{p-25d1e040.entry.js.map → p-8b831c94.entry.js.map} +0 -0
|
@@ -4,6 +4,7 @@ import { KritzelBaseHandler } from "./base.handler";
|
|
|
4
4
|
import { KritzelSelectionTool } from "../tools/selection-tool.class";
|
|
5
5
|
import { RemoveSelectionGroupCommand } from "../commands/remove-selection-group.command";
|
|
6
6
|
import { BatchCommand } from "../commands/batch.command";
|
|
7
|
+
import { KrtizelSelectionBox } from "../objects/selection-box.class";
|
|
7
8
|
export class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
8
9
|
globalContextMenuItems = [];
|
|
9
10
|
objectContextMenuItems = [];
|
|
@@ -17,23 +18,30 @@ export class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
if (this._core.store.state.skipContextMenu) {
|
|
20
|
-
this._core.store.
|
|
21
|
+
this._core.store.state.skipContextMenu = false;
|
|
21
22
|
return;
|
|
22
23
|
}
|
|
24
|
+
const selectionTool = this._core.store.state.activeTool;
|
|
25
|
+
selectionTool?.moveHandler?.cancelPendingDrag();
|
|
26
|
+
if (this._core.store.state.selectionBox) {
|
|
27
|
+
this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);
|
|
28
|
+
this._core.store.state.selectionBox = null;
|
|
29
|
+
this._core.store.state.isSelecting = false;
|
|
30
|
+
}
|
|
23
31
|
const selectedObject = this._core.getObjectFromPointerEvent(event, '.object');
|
|
24
|
-
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup)) {
|
|
32
|
+
if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup) && !(selectedObject instanceof KrtizelSelectionBox)) {
|
|
25
33
|
const selectionGroup = KritzelSelectionGroup.create(this._core);
|
|
26
34
|
selectionGroup.addOrRemove(selectedObject);
|
|
27
35
|
selectionGroup.isSelected = true;
|
|
28
36
|
selectionGroup.rotation = selectedObject.rotation;
|
|
29
|
-
this._core.store.
|
|
37
|
+
this._core.store.state.isSelecting = false;
|
|
30
38
|
const batch = new BatchCommand(this._core, this, [
|
|
31
39
|
new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup),
|
|
32
40
|
new AddSelectionGroupCommand(this._core, this, selectionGroup),
|
|
33
41
|
]);
|
|
34
42
|
this._core.history.executeCommand(batch);
|
|
35
43
|
}
|
|
36
|
-
this._core.store.
|
|
44
|
+
this._core.store.state.contextMenuItems = this._core.store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
|
|
37
45
|
let x = event.clientX - this._core.store.offsetX;
|
|
38
46
|
let y = event.clientY - this._core.store.offsetY;
|
|
39
47
|
const menuWidthEstimate = 150;
|
|
@@ -47,10 +55,10 @@ export class KritzelContextMenuHandler extends KritzelBaseHandler {
|
|
|
47
55
|
}
|
|
48
56
|
x = Math.max(margin, x);
|
|
49
57
|
y = Math.max(margin, y);
|
|
50
|
-
this._core.store.
|
|
51
|
-
this._core.store.
|
|
52
|
-
this._core.store.
|
|
53
|
-
this._core.store.
|
|
58
|
+
this._core.store.state.contextMenuX = x;
|
|
59
|
+
this._core.store.state.contextMenuY = y;
|
|
60
|
+
this._core.store.state.isContextMenuVisible = true;
|
|
61
|
+
this._core.store.state.isEnabled = false;
|
|
54
62
|
this._core.rerender();
|
|
55
63
|
}
|
|
56
64
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-menu.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/context-menu.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,yCAAyC,CAAC;AACnF,OAAO,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"context-menu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AI,CAAC;QAEnD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC;QAEzC,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { AddSelectionGroupCommand } from '../commands/add-selection-group.command';\r\nimport { KritzelSelectionGroup } from '../objects/selection-group.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelSelectionTool } from '../tools/selection-tool.class';\r\nimport { RemoveSelectionGroupCommand } from '../commands/remove-selection-group.command';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { KrtizelSelectionBox } from '../objects/selection-box.class';\r\n\r\nexport class KritzelContextMenuHandler extends KritzelBaseHandler {\r\n globalContextMenuItems = [];\r\n\r\n objectContextMenuItems = [];\r\n\r\n constructor(core: KritzelCore, globalContextMenuItems: any[], objectContextMenuItems: any[]) {\r\n super(core);\r\n this.globalContextMenuItems = globalContextMenuItems;\r\n this.objectContextMenuItems = objectContextMenuItems;\r\n }\r\n\r\n handleContextMenu(event: PointerEvent): void {\r\n if (!(this._core.store.state.activeTool instanceof KritzelSelectionTool)) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.skipContextMenu) {\r\n this._core.store.state.skipContextMenu = false;\r\n return;\r\n }\r\n\r\n const selectionTool = this._core.store.state.activeTool as KritzelSelectionTool;\r\n selectionTool?.moveHandler?.cancelPendingDrag();\r\n\r\n if (this._core.store.state.selectionBox) {\r\n this._core.store.state.objectsMap.remove(object => object instanceof KrtizelSelectionBox);\r\n this._core.store.state.selectionBox = null;\r\n this._core.store.state.isSelecting = false;\r\n }\r\n\r\n const selectedObject = this._core.getObjectFromPointerEvent(event, '.object');\r\n\r\n if (selectedObject && !(selectedObject instanceof KritzelSelectionGroup) && !(selectedObject instanceof KrtizelSelectionBox)) {\r\n const selectionGroup = KritzelSelectionGroup.create(this._core);\r\n selectionGroup.addOrRemove(selectedObject);\r\n selectionGroup.isSelected = true;\r\n selectionGroup.rotation = selectedObject.rotation;\r\n\r\n this._core.store.state.isSelecting = false;\r\n\r\n const batch = new BatchCommand(this._core, this, [\r\n new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup),\r\n new AddSelectionGroupCommand(this._core, this, selectionGroup),\r\n ]);\r\n\r\n this._core.history.executeCommand(batch);\r\n }\r\n\r\n this._core.store.state.contextMenuItems = this._core.store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;\r\n\r\n let x: number = event.clientX - this._core.store.offsetX;\r\n let y: number = event.clientY - this._core.store.offsetY;\r\n\r\n const menuWidthEstimate = 150;\r\n const menuHeightEstimate = 200;\r\n const margin = 10;\r\n\r\n if (x + menuWidthEstimate > window.innerWidth - margin) {\r\n x = window.innerWidth - menuWidthEstimate - margin;\r\n }\r\n\r\n if (y + menuHeightEstimate > window.innerHeight - margin) {\r\n y = window.innerHeight - menuHeightEstimate - margin;\r\n }\r\n\r\n x = Math.max(margin, x);\r\n y = Math.max(margin, y);\r\n\r\n this._core.store.state.contextMenuX = x;\r\n this._core.store.state.contextMenuY = y;\r\n this._core.store.state.isContextMenuVisible = true;\r\n\r\n this._core.store.state.isEnabled = false;\r\n\r\n this._core.rerender();\r\n }\r\n}\r\n"]}
|
|
@@ -26,8 +26,8 @@ export class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
26
26
|
},
|
|
27
27
|
{ key: 'v', ctrl: true, condition: c => !!c.store.state.copiedObjects && !c.store.state.activeText, action: c => c.paste() },
|
|
28
28
|
// Text editing
|
|
29
|
-
{ key: 'a', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.selectAll() },
|
|
30
|
-
{ key: 'v', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.insertFromClipboard() },
|
|
29
|
+
// { key: 'a', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.selectAll() },
|
|
30
|
+
// { key: 'v', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.insertFromClipboard() },
|
|
31
31
|
// Object layering
|
|
32
32
|
{ key: '+', ctrl: true, condition: c => !!c.store.state.selectionGroup, action: c => c.bringForward() },
|
|
33
33
|
{ key: '-', ctrl: true, condition: c => !!c.store.state.selectionGroup, action: c => c.sendBackward() },
|
|
@@ -44,7 +44,7 @@ export class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
44
44
|
toolInstance.onActivate();
|
|
45
45
|
}
|
|
46
46
|
handleKeyDown(event) {
|
|
47
|
-
this._core.store.
|
|
47
|
+
this._core.store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
48
48
|
const shortcut = this.shortcuts.find(s => s.key === event.key && !!s.ctrl === event.ctrlKey && !!s.shift === event.shiftKey && (!s.condition || s.condition(this._core)));
|
|
49
49
|
if (shortcut) {
|
|
50
50
|
event.preventDefault();
|
|
@@ -52,7 +52,7 @@ export class KritzelKeyHandler extends KritzelBaseHandler {
|
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
handleKeyUp(event) {
|
|
55
|
-
this._core.store.
|
|
55
|
+
this._core.store.state.isCtrlKeyPressed = event.ctrlKey;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
//# sourceMappingURL=key.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"key.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/key.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,MAAM,OAAO,iBAAkB,SAAQ,kBAAkB;IAE/C,SAAS,GAAsB;QACrC,UAAU;QACV,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,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elCore } from '../core/core.class';\r\nimport { KritzelShortcut } from '../../interfaces/shortcut.interface';\r\n\r\nexport class KritzelKeyHandler extends KritzelBaseHandler {\r\n\r\n private shortcuts: KritzelShortcut[] = [\r\n // General\r\n { key: 'Escape', condition: c => !!c.store.state.selectionGroup, action: c => c.clearSelection() },\r\n { key: 'Delete', condition: c => !!c.store.state.selectionGroup, action: c => c.delete() },\r\n\r\n // History\r\n { key: 'z', ctrl: true, action: c => c.history.undo() },\r\n { key: 'y', ctrl: true, action: c => c.history.redo() },\r\n\r\n // Tool selection\r\n { key: 's', ctrl: true, action: () => this.switchTool('selection') },\r\n { key: 'b', ctrl: true, action: () => this.switchTool('brush') },\r\n { key: 'e', ctrl: true, action: () => this.switchTool('eraser') },\r\n { key: 'i', ctrl: true, action: () => this.switchTool('image') },\r\n { key: 'x', ctrl: true, action: () => this.switchTool('text') },\r\n\r\n // Clipboard\r\n {\r\n key: 'c',\r\n ctrl: true,\r\n condition: c => !!c.store.state.selectionGroup,\r\n action: c => {\r\n c.copy();\r\n c.rerender();\r\n },\r\n },\r\n { key: 'v', ctrl: true, condition: c => !!c.store.state.copiedObjects && !c.store.state.activeText, action: c => c.paste() },\r\n\r\n // Text editing\r\n // { key: 'a', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.selectAll() },\r\n // { key: 'v', ctrl: true, condition: c => !!c.store.state.activeText, action: c => c.store.state.activeText.insertFromClipboard() },\r\n\r\n // Object layering\r\n { key: '+', ctrl: true, condition: c => !!c.store.state.selectionGroup, action: c => c.bringForward() },\r\n { key: '-', ctrl: true, condition: c => !!c.store.state.selectionGroup, action: c => c.sendBackward() },\r\n { key: '*', shift: true, condition: c => !!c.store.state.selectionGroup, action: c => c.bringToFront() },\r\n { key: '_', shift: true, condition: c => !!c.store.state.selectionGroup, action: c => c.sendToBack() },\r\n ];\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private switchTool(tool: string) {\r\n const toolInstance = KritzelToolRegistry.getTool(tool);\r\n this._core.store.setState('activeTool', toolInstance);\r\n this._core.deselectAllObjects();\r\n toolInstance.onActivate();\r\n }\r\n\r\n handleKeyDown(event: KeyboardEvent): void {\r\n this._core.store.state.isCtrlKeyPressed = event.ctrlKey;\r\n\r\n const shortcut = this.shortcuts.find(s => s.key === event.key && !!s.ctrl === event.ctrlKey && !!s.shift === event.shiftKey && (!s.condition || s.condition(this._core)));\r\n\r\n if (shortcut) {\r\n event.preventDefault();\r\n shortcut.action(this._core);\r\n } \r\n }\r\n\r\n handleKeyUp(event: KeyboardEvent): void {\r\n this._core.store.state.isCtrlKeyPressed = event.ctrlKey;\r\n }\r\n}\r\n"]}
|
|
@@ -9,6 +9,7 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
9
9
|
endX;
|
|
10
10
|
endY;
|
|
11
11
|
hasMoved = false;
|
|
12
|
+
trackedPointerId = null;
|
|
12
13
|
constructor(core) {
|
|
13
14
|
super(core);
|
|
14
15
|
}
|
|
@@ -20,6 +21,11 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
20
21
|
this.endX = 0;
|
|
21
22
|
this.endY = 0;
|
|
22
23
|
this.hasMoved = false;
|
|
24
|
+
this.trackedPointerId = null;
|
|
25
|
+
}
|
|
26
|
+
cancelPendingDrag() {
|
|
27
|
+
this._core.store.state.isDragging = false;
|
|
28
|
+
this.reset();
|
|
23
29
|
}
|
|
24
30
|
handlePointerDown(event) {
|
|
25
31
|
if (event.pointerType === 'mouse') {
|
|
@@ -27,13 +33,20 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
27
33
|
if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
|
|
28
34
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
29
35
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
30
|
-
this._core.store.
|
|
36
|
+
this._core.store.state.isDragging = true;
|
|
31
37
|
this.dragStartX = clientX;
|
|
32
38
|
this.dragStartY = clientY;
|
|
33
39
|
this.startX = this.dragStartX;
|
|
34
40
|
this.startY = this.dragStartY;
|
|
41
|
+
this.trackedPointerId = event.pointerId;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
this.trackedPointerId = null;
|
|
35
45
|
}
|
|
36
46
|
}
|
|
47
|
+
else {
|
|
48
|
+
this.trackedPointerId = null;
|
|
49
|
+
}
|
|
37
50
|
}
|
|
38
51
|
if (event.pointerType === 'touch') {
|
|
39
52
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
@@ -45,11 +58,18 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
45
58
|
this.dragStartY = y;
|
|
46
59
|
this.startX = x;
|
|
47
60
|
this.startY = y;
|
|
61
|
+
this.trackedPointerId = event.pointerId;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
this.trackedPointerId = null;
|
|
48
65
|
}
|
|
49
66
|
}
|
|
50
67
|
}
|
|
51
68
|
}
|
|
52
69
|
handlePointerMove(event) {
|
|
70
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
53
73
|
if (event.pointerType === 'mouse') {
|
|
54
74
|
if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {
|
|
55
75
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
@@ -70,7 +90,7 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
70
90
|
!this._core.store.state.isRotationHandleSelected) {
|
|
71
91
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
72
92
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
73
|
-
this._core.store.
|
|
93
|
+
this._core.store.state.isDragging = true;
|
|
74
94
|
this.endX = x;
|
|
75
95
|
this.endY = y;
|
|
76
96
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
@@ -87,26 +107,28 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
87
107
|
}
|
|
88
108
|
}
|
|
89
109
|
handlePointerUp(event) {
|
|
110
|
+
if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
90
113
|
if (event.pointerType === 'mouse') {
|
|
91
114
|
if (this._core.store.state.isDragging) {
|
|
92
|
-
this._core.store.
|
|
115
|
+
this._core.store.state.isDragging = false;
|
|
93
116
|
if (this.hasMoved) {
|
|
94
117
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
95
|
-
this._core.store.
|
|
118
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
96
119
|
}
|
|
97
|
-
this.reset();
|
|
98
120
|
}
|
|
99
121
|
}
|
|
100
122
|
if (event.pointerType === 'touch') {
|
|
101
123
|
if (this._core.store.state.isDragging) {
|
|
102
|
-
this._core.store.
|
|
124
|
+
this._core.store.state.isDragging = false;
|
|
103
125
|
if (this.hasMoved) {
|
|
104
126
|
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
105
|
-
this._core.store.
|
|
127
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
106
128
|
}
|
|
107
|
-
this.reset();
|
|
108
129
|
}
|
|
109
130
|
}
|
|
131
|
+
this.reset();
|
|
110
132
|
}
|
|
111
133
|
}
|
|
112
134
|
//# sourceMappingURL=move.handler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"move.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/move.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,OAAO,kBAAmB,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,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;gBACvD,CAAC;gBAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { MoveSelectionGroupCommand } from '../commands/move-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nexport class KritzelMoveHandler extends KritzelBaseHandler {\r\n dragStartX: number;\r\n dragStartY: number;\r\n\r\n startX: number;\r\n startY: number;\r\n\r\n endX: number;\r\n endY: number;\r\n\r\n hasMoved: boolean = false;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.dragStartX = 0;\r\n this.dragStartY = 0;\r\n this.startX = 0;\r\n this.startY = 0;\r\n this.endX = 0;\r\n this.endY = 0;\r\n this.hasMoved = false;\r\n }\r\n\r\n handlePointerDown(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isDragging', true);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.startX = this.dragStartX;\r\n this.startY = this.dragStartY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (this._core.store.state.pointers.size === 1) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n this.startX = x;\r\n this.startY = y;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this.endX = clientX;\r\n this.endY = clientY;\r\n this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.hasMoved = true;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (\r\n this._core.store.state.pointers.size === 1 &&\r\n this._core.store.state.selectionGroup &&\r\n !this._core.store.state.isResizeHandleSelected &&\r\n !this._core.store.state.isRotationHandleSelected\r\n ) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isDragging', true);\r\n this.endX = x;\r\n this.endY = y;\r\n \r\n const moveDeltaX = Math.abs(x - this.startX);\r\n const moveDeltaY = Math.abs(y - this.startY);\r\n const moveThreshold = 5;\r\n \r\n if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n \r\n this._core.store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n this.hasMoved = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.setState('isDragging', false);\r\n\r\n if (this.hasMoved) {\r\n this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));\r\n this._core.store.setState('hasObjectsChanged', true);\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.setState('isDragging', false);\r\n\r\n if (this.hasMoved) {\r\n this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));\r\n this._core.store.setState('hasObjectsChanged', true);\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"move.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/move.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACxD,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,MAAM,CAAS;IACf,MAAM,CAAS;IAEf,IAAI,CAAS;IACb,IAAI,CAAS;IAEb,QAAQ,GAAY,KAAK,CAAC;IAClB,gBAAgB,GAAkB,IAAI,CAAC;IAE/C,YAAY,IAAiB;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAChB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QACd,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC;IAC/B,CAAC;IAED,iBAAiB;QACf,IAAI,CAA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AAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;oBACzI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAClD,CAAC;YACH,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { MoveSelectionGroupCommand } from '../commands/move-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nexport class KritzelMoveHandler extends KritzelBaseHandler {\r\n dragStartX: number;\r\n dragStartY: number;\r\n\r\n startX: number;\r\n startY: number;\r\n\r\n endX: number;\r\n endY: number;\r\n\r\n hasMoved: boolean = false;\r\n private trackedPointerId: number | null = null;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.dragStartX = 0;\r\n this.dragStartY = 0;\r\n this.startX = 0;\r\n this.startY = 0;\r\n this.endX = 0;\r\n this.endY = 0;\r\n this.hasMoved = false;\r\n this.trackedPointerId = null;\r\n }\r\n\r\n cancelPendingDrag(): void {\r\n this._core.store.state.isDragging = false;\r\n this.reset();\r\n }\r\n\r\n handlePointerDown(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isDragging = true;\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.startX = this.dragStartX;\r\n this.startY = this.dragStartY;\r\n this.trackedPointerId = event.pointerId;\r\n } else {\r\n this.trackedPointerId = null;\r\n }\r\n } else {\r\n this.trackedPointerId = null;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (this._core.store.state.pointers.size === 1) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n this.startX = x;\r\n this.startY = y;\r\n this.trackedPointerId = event.pointerId;\r\n } else {\r\n this.trackedPointerId = null;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent) {\r\n if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {\r\n return;\r\n }\r\n\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this.endX = clientX;\r\n this.endY = clientY;\r\n this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.hasMoved = true;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (\r\n this._core.store.state.pointers.size === 1 &&\r\n this._core.store.state.selectionGroup &&\r\n !this._core.store.state.isResizeHandleSelected &&\r\n !this._core.store.state.isRotationHandleSelected\r\n ) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isDragging = true;\r\n this.endX = x;\r\n this.endY = y;\r\n \r\n const moveDeltaX = Math.abs(x - this.startX);\r\n const moveDeltaY = Math.abs(y - this.startY);\r\n const moveThreshold = 5;\r\n \r\n if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n \r\n this._core.store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n this.hasMoved = true;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent) {\r\n if (this.trackedPointerId === null || this.trackedPointerId !== event.pointerId) {\r\n return;\r\n }\r\n\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.state.isDragging = false;\r\n\r\n if (this.hasMoved) {\r\n this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.state.isDragging = false;\r\n\r\n if (this.hasMoved) {\r\n this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n }\r\n }\r\n\r\n this.reset();\r\n }\r\n}\r\n"]}
|
|
@@ -22,7 +22,7 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
22
22
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
23
23
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
24
24
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
25
|
-
this._core.store.
|
|
25
|
+
this._core.store.state.isResizing = true;
|
|
26
26
|
this.initialMouseX = clientX;
|
|
27
27
|
this.initialMouseY = clientY;
|
|
28
28
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -42,7 +42,7 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
42
42
|
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
43
43
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
44
44
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
45
|
-
this._core.store.
|
|
45
|
+
this._core.store.state.isResizing = true;
|
|
46
46
|
this.initialMouseX = clientX;
|
|
47
47
|
this.initialMouseY = clientY;
|
|
48
48
|
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
@@ -136,16 +136,16 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
136
136
|
if (event.pointerType === 'mouse') {
|
|
137
137
|
if (this._core.store.state.isResizing) {
|
|
138
138
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
139
|
-
this._core.store.
|
|
140
|
-
this._core.store.
|
|
139
|
+
this._core.store.state.isResizing = false;
|
|
140
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
141
141
|
this.reset();
|
|
142
142
|
}
|
|
143
143
|
}
|
|
144
144
|
if (event.pointerType === 'touch') {
|
|
145
145
|
if (this._core.store.state.isResizing) {
|
|
146
146
|
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
147
|
-
this._core.store.
|
|
148
|
-
this._core.store.
|
|
147
|
+
this._core.store.state.isResizing = false;
|
|
148
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
149
149
|
this.reset();
|
|
150
150
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
151
151
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/resize.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF,OAAO,EAAE,kBAAkB,EAAE,MAAM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C,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;gBAErD,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAEvJ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAC/C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;gBAErD,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { ResizeSelectionGroupCommand } from '../commands/resize-selection-group.command';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialMouseX = 0;\r\n this.initialMouseY = 0;\r\n this.initialSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.newSize = { x: 0, y: 0, width: 0, height: 0 };\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isResizing', true);\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isResizing', true);\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));\r\n\r\n this._core.store.setState('isResizing', false);\r\n this._core.store.setState('hasObjectsChanged', true);\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));\r\n\r\n this._core.store.setState('isResizing', false);\r\n this._core.store.setState('hasObjectsChanged', true);\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\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CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAEvJ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAEhD,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAEvJ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAEhD,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { ResizeSelectionGroupCommand } from '../commands/resize-selection-group.command';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialMouseX = 0;\r\n this.initialMouseY = 0;\r\n this.initialSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.newSize = { x: 0, y: 0, width: 0, height: 0 };\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));\r\n\r\n this._core.store.state.isResizing = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));\r\n\r\n this._core.store.state.isResizing = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
@@ -20,7 +20,7 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
20
20
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
21
21
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
22
22
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
23
|
-
this._core.store.
|
|
23
|
+
this._core.store.state.isRotating = true;
|
|
24
24
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
25
25
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
26
26
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -41,7 +41,7 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
41
41
|
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
42
42
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
43
43
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
44
|
-
this._core.store.
|
|
44
|
+
this._core.store.state.isRotating = true;
|
|
45
45
|
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
46
46
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
47
47
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
@@ -92,16 +92,16 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
92
92
|
if (event.pointerType === 'mouse') {
|
|
93
93
|
if (this._core.store.state.isRotating) {
|
|
94
94
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
95
|
-
this._core.store.
|
|
96
|
-
this._core.store.
|
|
95
|
+
this._core.store.state.isRotating = false;
|
|
96
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
97
97
|
this.reset();
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
if (event.pointerType === 'touch') {
|
|
101
101
|
if (this._core.store.state.isRotating) {
|
|
102
102
|
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
103
|
-
this._core.store.
|
|
104
|
-
this._core.store.
|
|
103
|
+
this._core.store.state.isRotating = false;
|
|
104
|
+
this._core.store.state.hasObjectsChanged = true;
|
|
105
105
|
this.reset();
|
|
106
106
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
107
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/rotation.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,eAAe,GAAW,CAAC,CAAC;IAE5B,QAAQ,GAAW,CAAC,CAAC;IAErB,gBAAgB,GAA6B,EAAE,CAAC;IAEhD,6BAA6B,GAAW,CAAC,CAAC;IAE1C,YAAY,IAAiB;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,eAAe,GAA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,CAAC,6BAA6B,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAC/C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;gBAErD,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { RotateSelectionGroupCommand } from '../commands/rotate-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseObject } from '../objects/base-object.class';\r\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n unchangedObjects: KritzelBaseObject<any>[] = [];\r\n\r\n initialSelectionGroupRotation: number = 0;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n this.unchangedObjects = [];\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isRotating', true);\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isRotating', true);\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));\r\n\r\n this._core.store.setState('isRotating', false);\r\n this._core.store.setState('hasObjectsChanged', true);\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));\r\n\r\n this._core.store.setState('isRotating', false);\r\n this._core.store.setState('hasObjectsChanged', true);\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"rotation.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/rotation.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,eAAe,GAAW,CAAC,CAAC;IAE5B,QAAQ,GAAW,CAAC,CAAC;IAErB,gBAAgB,GAA6B,EAAE,CAAC;IAEhD,6BAA6B,GAAW,CAAC,CAAC;IAE1C,YAAY,IAAiB;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED,iBAAiB,CAAC,KAAmB;QACnC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1C,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,KA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../../helpers/event.helper';\r\nimport { RotateSelectionGroupCommand } from '../commands/rotate-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseObject } from '../objects/base-object.class';\r\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n unchangedObjects: KritzelBaseObject<any>[] = [];\r\n\r\n initialSelectionGroupRotation: number = 0;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n this.unchangedObjects = [];\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isRotating = true;\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isRotating = true;\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));\r\n\r\n this._core.store.state.isRotating = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));\r\n\r\n this._core.store.state.isRotating = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|