kritzel-stencil 0.0.108 → 0.0.110

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js +854 -833
  2. package/dist/cjs/kritzel-brush-style_18.cjs.entry.js.map +1 -1
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/stencil.cjs.js +1 -1
  5. package/dist/collection/classes/commands/remove-selection-group.command.js +1 -1
  6. package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
  7. package/dist/collection/classes/handlers/context-menu.handler.js +2 -47
  8. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  9. package/dist/collection/classes/handlers/move.handler.js +62 -55
  10. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  11. package/dist/collection/classes/handlers/resize.handler.js +122 -113
  12. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  13. package/dist/collection/classes/handlers/rotation.handler.js +74 -66
  14. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  15. package/dist/collection/classes/handlers/selection.handler.js +59 -50
  16. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  17. package/dist/collection/classes/objects/base-object.class.js +3 -0
  18. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  19. package/dist/collection/classes/objects/text.class.js +11 -1
  20. package/dist/collection/classes/objects/text.class.js.map +1 -1
  21. package/dist/collection/classes/tools/base-tool.class.js +3 -18
  22. package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
  23. package/dist/collection/classes/tools/brush-tool.class.js +79 -71
  24. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  25. package/dist/collection/classes/tools/eraser-tool.class.js +61 -56
  26. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  27. package/dist/collection/classes/tools/selection-tool.class.js +93 -73
  28. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  29. package/dist/collection/classes/tools/text-tool.class.js +73 -70
  30. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  31. package/dist/collection/classes/viewport.class.js +76 -69
  32. package/dist/collection/classes/viewport.class.js.map +1 -1
  33. package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +6 -0
  34. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +6 -0
  35. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +66 -120
  36. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  37. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -16
  38. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  39. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +10 -2
  40. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +9 -4
  41. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  42. package/dist/collection/configs/default-engine-state.js +1 -1
  43. package/dist/collection/configs/default-engine-state.js.map +1 -1
  44. package/dist/collection/helpers/devices.helper.js +6 -0
  45. package/dist/collection/helpers/devices.helper.js.map +1 -0
  46. package/dist/collection/helpers/event.helper.js +43 -34
  47. package/dist/collection/helpers/event.helper.js.map +1 -1
  48. package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
  49. package/dist/collection/interfaces/object.interface.js.map +1 -1
  50. package/dist/collection/interfaces/tool.interface.js.map +1 -1
  51. package/dist/components/kritzel-context-menu.js +1 -1
  52. package/dist/components/kritzel-controls.js +1 -1
  53. package/dist/components/kritzel-editor.js +5 -5
  54. package/dist/components/kritzel-editor.js.map +1 -1
  55. package/dist/components/kritzel-engine.js +1 -1
  56. package/dist/components/{p-BNfHRlWL.js → p-7Ns73-wN.js} +237 -220
  57. package/dist/components/p-7Ns73-wN.js.map +1 -0
  58. package/dist/components/{p-Cbu5RSmC.js → p-BmAloSfd.js} +3 -4
  59. package/dist/components/p-BmAloSfd.js.map +1 -0
  60. package/dist/components/{p-Box62paJ.js → p-Ch6TgHX3.js} +18 -8
  61. package/dist/components/p-Ch6TgHX3.js.map +1 -0
  62. package/dist/components/{p-CqJr3YCp.js → p-mD9nNnTx.js} +618 -622
  63. package/dist/components/p-mD9nNnTx.js.map +1 -0
  64. package/dist/esm/kritzel-brush-style_18.entry.js +854 -833
  65. package/dist/esm/kritzel-brush-style_18.entry.js.map +1 -1
  66. package/dist/esm/loader.js +1 -1
  67. package/dist/esm/stencil.js +1 -1
  68. package/dist/stencil/p-d23bb1ad.entry.js +2 -0
  69. package/dist/stencil/p-d23bb1ad.entry.js.map +1 -0
  70. package/dist/stencil/stencil.esm.js +1 -1
  71. package/dist/types/classes/handlers/context-menu.handler.d.ts +1 -2
  72. package/dist/types/classes/handlers/move.handler.d.ts +3 -6
  73. package/dist/types/classes/handlers/resize.handler.d.ts +3 -6
  74. package/dist/types/classes/handlers/rotation.handler.d.ts +3 -6
  75. package/dist/types/classes/handlers/selection.handler.d.ts +3 -6
  76. package/dist/types/classes/objects/base-object.class.d.ts +1 -0
  77. package/dist/types/classes/objects/text.class.d.ts +1 -0
  78. package/dist/types/classes/tools/base-tool.class.d.ts +3 -8
  79. package/dist/types/classes/tools/brush-tool.class.d.ts +3 -6
  80. package/dist/types/classes/tools/eraser-tool.class.d.ts +3 -6
  81. package/dist/types/classes/tools/selection-tool.class.d.ts +4 -7
  82. package/dist/types/classes/tools/text-tool.class.d.ts +2 -4
  83. package/dist/types/classes/viewport.class.d.ts +3 -6
  84. package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +5 -10
  85. package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +0 -1
  86. package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +1 -0
  87. package/dist/types/components.d.ts +0 -2
  88. package/dist/types/helpers/devices.helper.d.ts +3 -0
  89. package/dist/types/helpers/event.helper.d.ts +2 -6
  90. package/dist/types/interfaces/engine-state.interface.d.ts +1 -1
  91. package/dist/types/interfaces/object.interface.d.ts +1 -0
  92. package/dist/types/interfaces/tool.interface.d.ts +3 -8
  93. package/package.json +1 -1
  94. package/dist/components/p-BNfHRlWL.js.map +0 -1
  95. package/dist/components/p-Box62paJ.js.map +0 -1
  96. package/dist/components/p-Cbu5RSmC.js.map +0 -1
  97. package/dist/components/p-CqJr3YCp.js.map +0 -1
  98. package/dist/stencil/p-3a7d7b58.entry.js +0 -2
  99. package/dist/stencil/p-3a7d7b58.entry.js.map +0 -1
@@ -10,131 +10,140 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
10
10
  this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
11
11
  this.newSize = { x: 0, y: 0, width: 0, height: 0 };
12
12
  }
13
- handleMouseDown(event) {
14
- if (KritzelEventHelper.isLeftClick(event)) {
15
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
16
- const clientX = event.clientX - this._store.offsetX;
17
- const clientY = event.clientY - this._store.offsetY;
18
- this._store.state.isResizing = true;
19
- this.initialMouseX = clientX;
20
- this.initialMouseY = clientY;
21
- this.initialSize.width = this._store.state.selectionGroup.width;
22
- this.initialSize.height = this._store.state.selectionGroup.height;
23
- this.initialSize.x = this._store.state.selectionGroup.translateX;
24
- this.initialSize.y = this._store.state.selectionGroup.translateY;
13
+ handlePointerDown(event) {
14
+ if (event.pointerType === 'mouse') {
15
+ if (KritzelEventHelper.isLeftClick(event)) {
16
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
17
+ const clientX = event.clientX - this._store.offsetX;
18
+ const clientY = event.clientY - this._store.offsetY;
19
+ this._store.state.isResizing = true;
20
+ this.initialMouseX = clientX;
21
+ this.initialMouseY = clientY;
22
+ this.initialSize.width = this._store.state.selectionGroup.width;
23
+ this.initialSize.height = this._store.state.selectionGroup.height;
24
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
25
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
26
+ }
25
27
  }
26
28
  }
27
- }
28
- handleMouseMove(event) {
29
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
30
- const clientX = event.clientX - this._store.offsetX;
31
- const clientY = event.clientY - this._store.offsetY;
32
- const dx = clientX - this.initialMouseX;
33
- const dy = clientY - this.initialMouseY;
34
- switch (this._store.state.resizeHandleType) {
35
- case KritzelHandleType.TopLeft:
36
- this.newSize.width = this.initialSize.width - dx;
37
- this.newSize.height = this.initialSize.height - dy;
38
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
39
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
40
- break;
41
- case KritzelHandleType.TopRight:
42
- this.newSize.width = this.initialSize.width + dx;
43
- this.newSize.height = this.initialSize.height - dy;
44
- this.newSize.x = this.initialSize.x;
45
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
46
- break;
47
- case KritzelHandleType.BottomLeft:
48
- this.newSize.width = this.initialSize.width - dx;
49
- this.newSize.height = this.initialSize.height + dy;
50
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
51
- this.newSize.y = this.initialSize.y;
52
- break;
53
- case KritzelHandleType.BottomRight:
54
- this.newSize.width = this.initialSize.width + dx;
55
- this.newSize.height = this.initialSize.height + dy;
56
- this.newSize.x = this.initialSize.x;
57
- this.newSize.y = this.initialSize.y;
58
- break;
29
+ if (event.pointerType === 'touch') {
30
+ const activePointers = Array.from(this._store.state.pointers.values());
31
+ const firstTouch = activePointers[0];
32
+ if (!firstTouch) {
33
+ return;
34
+ }
35
+ if (activePointers.length === 1) {
36
+ if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
37
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
38
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
39
+ this._store.state.isResizing = true;
40
+ this.initialMouseX = clientX;
41
+ this.initialMouseY = clientY;
42
+ this.initialSize.width = this._store.state.selectionGroup.width;
43
+ this.initialSize.height = this._store.state.selectionGroup.height;
44
+ this.initialSize.x = this._store.state.selectionGroup.translateX;
45
+ this.initialSize.y = this._store.state.selectionGroup.translateY;
46
+ clearTimeout(this._store.state.longTouchTimeout);
47
+ }
59
48
  }
60
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
61
- this._store.rerender();
62
- }
63
- }
64
- handleMouseUp(_event) {
65
- if (this._store.state.isResizing) {
66
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
67
- this._store.history.executeCommand(resizeSelectionGroupCommand);
68
- this._store.state.isResizing = false;
69
- this._store.rerender();
70
49
  }
71
50
  }
72
- handleTouchStart(event) {
73
- const firstTouch = event.touches[0];
74
- if (!firstTouch) {
75
- return;
51
+ handlePointerMove(event) {
52
+ if (event.pointerType === 'mouse') {
53
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
54
+ const clientX = event.clientX - this._store.offsetX;
55
+ const clientY = event.clientY - this._store.offsetY;
56
+ const dx = clientX - this.initialMouseX;
57
+ const dy = clientY - this.initialMouseY;
58
+ switch (this._store.state.resizeHandleType) {
59
+ case KritzelHandleType.TopLeft:
60
+ this.newSize.width = this.initialSize.width - dx;
61
+ this.newSize.height = this.initialSize.height - dy;
62
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
63
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
64
+ break;
65
+ case KritzelHandleType.TopRight:
66
+ this.newSize.width = this.initialSize.width + dx;
67
+ this.newSize.height = this.initialSize.height - dy;
68
+ this.newSize.x = this.initialSize.x;
69
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
70
+ break;
71
+ case KritzelHandleType.BottomLeft:
72
+ this.newSize.width = this.initialSize.width - dx;
73
+ this.newSize.height = this.initialSize.height + dy;
74
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
75
+ this.newSize.y = this.initialSize.y;
76
+ break;
77
+ case KritzelHandleType.BottomRight:
78
+ this.newSize.width = this.initialSize.width + dx;
79
+ this.newSize.height = this.initialSize.height + dy;
80
+ this.newSize.x = this.initialSize.x;
81
+ this.newSize.y = this.initialSize.y;
82
+ break;
83
+ }
84
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
85
+ this._store.rerender();
86
+ }
76
87
  }
77
- if (this._store.state.touchCount === 1) {
78
- if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {
79
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
80
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
81
- this._store.state.isResizing = true;
82
- this.initialMouseX = clientX;
83
- this.initialMouseY = clientY;
84
- this.initialSize.width = this._store.state.selectionGroup.width;
85
- this.initialSize.height = this._store.state.selectionGroup.height;
86
- this.initialSize.x = this._store.state.selectionGroup.translateX;
87
- this.initialSize.y = this._store.state.selectionGroup.translateY;
88
+ if (event.pointerType === 'touch') {
89
+ const activePointers = Array.from(this._store.state.pointers.values());
90
+ const oneFingerTouch = activePointers[0];
91
+ if (!oneFingerTouch) {
92
+ return;
93
+ }
94
+ if (this._store.state.isResizing && this._store.state.selectionGroup) {
95
+ const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
96
+ const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
97
+ const dx = clientX - this.initialMouseX;
98
+ const dy = clientY - this.initialMouseY;
99
+ switch (this._store.state.resizeHandleType) {
100
+ case KritzelHandleType.TopLeft:
101
+ this.newSize.width = this.initialSize.width - dx;
102
+ this.newSize.height = this.initialSize.height - dy;
103
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
104
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
105
+ break;
106
+ case KritzelHandleType.TopRight:
107
+ this.newSize.width = this.initialSize.width + dx;
108
+ this.newSize.height = this.initialSize.height - dy;
109
+ this.newSize.x = this.initialSize.x;
110
+ this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
111
+ break;
112
+ case KritzelHandleType.BottomLeft:
113
+ this.newSize.width = this.initialSize.width - dx;
114
+ this.newSize.height = this.initialSize.height + dy;
115
+ this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
116
+ this.newSize.y = this.initialSize.y;
117
+ break;
118
+ case KritzelHandleType.BottomRight:
119
+ this.newSize.width = this.initialSize.width + dx;
120
+ this.newSize.height = this.initialSize.height + dy;
121
+ this.newSize.x = this.initialSize.x;
122
+ this.newSize.y = this.initialSize.y;
123
+ break;
124
+ }
125
+ this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
88
126
  clearTimeout(this._store.state.longTouchTimeout);
89
127
  }
90
128
  }
91
129
  }
92
- handleTouchMove(event) {
93
- const oneFingerTouch = event.touches[0];
94
- if (!oneFingerTouch) {
95
- return;
96
- }
97
- if (this._store.state.isResizing && this._store.state.selectionGroup) {
98
- const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);
99
- const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);
100
- const dx = clientX - this.initialMouseX;
101
- const dy = clientY - this.initialMouseY;
102
- switch (this._store.state.resizeHandleType) {
103
- case KritzelHandleType.TopLeft:
104
- this.newSize.width = this.initialSize.width - dx;
105
- this.newSize.height = this.initialSize.height - dy;
106
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
107
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
108
- break;
109
- case KritzelHandleType.TopRight:
110
- this.newSize.width = this.initialSize.width + dx;
111
- this.newSize.height = this.initialSize.height - dy;
112
- this.newSize.x = this.initialSize.x;
113
- this.newSize.y = dy / this._store.state.scale + this.initialSize.y;
114
- break;
115
- case KritzelHandleType.BottomLeft:
116
- this.newSize.width = this.initialSize.width - dx;
117
- this.newSize.height = this.initialSize.height + dy;
118
- this.newSize.x = dx / this._store.state.scale + this.initialSize.x;
119
- this.newSize.y = this.initialSize.y;
120
- break;
121
- case KritzelHandleType.BottomRight:
122
- this.newSize.width = this.initialSize.width + dx;
123
- this.newSize.height = this.initialSize.height + dy;
124
- this.newSize.x = this.initialSize.x;
125
- this.newSize.y = this.initialSize.y;
126
- break;
130
+ handlePointerUp(event) {
131
+ if (event.pointerType === 'mouse') {
132
+ if (this._store.state.isResizing) {
133
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
134
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
135
+ this._store.state.isResizing = false;
136
+ this._store.rerender();
127
137
  }
128
- this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
129
- clearTimeout(this._store.state.longTouchTimeout);
130
138
  }
131
- }
132
- handleTouchEnd(_event) {
133
- if (this._store.state.isResizing) {
134
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
135
- this._store.history.executeCommand(resizeSelectionGroupCommand);
136
- this._store.state.isResizing = false;
137
- clearTimeout(this._store.state.longTouchTimeout);
139
+ if (event.pointerType === 'touch') {
140
+ if (this._store.state.isResizing) {
141
+ const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));
142
+ this._store.history.executeCommand(resizeSelectionGroupCommand);
143
+ this._store.state.isResizing = false;
144
+ this._store.rerender();
145
+ clearTimeout(this._store.state.longTouchTimeout);
146
+ }
138
147
  }
139
148
  }
140
149
  }
@@ -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,gBAAgB,CAAC;AAEpD,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAQ1D,YAAY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2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;YACzJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAC;YAChE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;YAErC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnD,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 { KritzelStore } from '../store.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(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handleMouseDown(event: MouseEvent): void {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._store.state.selectionGroup.width;\r\n this.initialSize.height = this._store.state.selectionGroup.height;\r\n this.initialSize.x = this._store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._store.state.selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n handleMouseMove(event: MouseEvent): void {\r\n if (this._store.state.isResizing && this._store.state.selectionGroup) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._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._store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._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._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._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._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleMouseUp(_event: MouseEvent): void {\r\n if (this._store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n this._store.history.executeCommand(resizeSelectionGroupCommand);\r\n this._store.state.isResizing = false;\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleTouchStart(event: TouchEvent): void {\r\n const firstTouch = event.touches[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._store.state.touchCount === 1) {\r\n if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n this._store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._store.state.selectionGroup.width;\r\n this.initialSize.height = this._store.state.selectionGroup.height;\r\n this.initialSize.x = this._store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handleTouchMove(event: TouchEvent): void {\r\n const oneFingerTouch = event.touches[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n if (this._store.state.isResizing && this._store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._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._store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._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._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._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._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n\r\n handleTouchEnd(_event: TouchEvent): void {\r\n if (this._store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n this._store.history.executeCommand(resizeSelectionGroupCommand);\r\n this._store.state.isResizing = false;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n}\r\n"]}
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,gBAAgB,CAAC;AAEpD,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAQ1D,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QARf,kBAAa,GAAW,CAAC,CAAC;QAC1B,kBAAa,GAAW,CAAC,CAAC;QAE1B,gBAAW,GAA4D,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAE3G,YAAO,GAA4D,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAIvG,CAAC;IAED,iBAAiB,CAAC,KAAmB;QACnC,IAAI,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MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACjC,MAAM,2BAA2B,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACzJ,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,2BAA2B,CAAC,CAAC;gBAChE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBACrC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBAEvB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACnD,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 { KritzelStore } from '../store.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(store: KritzelStore) {\r\n super(store);\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._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._store.state.selectionGroup.width;\r\n this.initialSize.height = this._store.state.selectionGroup.height;\r\n this.initialSize.x = this._store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._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._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._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n this._store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._store.state.selectionGroup.width;\r\n this.initialSize.height = this._store.state.selectionGroup.height;\r\n this.initialSize.x = this._store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._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._store.state.isResizing && this._store.state.selectionGroup) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._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._store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._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._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._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._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._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._store.state.isResizing && this._store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._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._store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._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._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._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._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._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._store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n this._store.history.executeCommand(resizeSelectionGroupCommand);\r\n this._store.state.isResizing = false;\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if( event.pointerType === 'touch') {\r\n if (this._store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n this._store.history.executeCommand(resizeSelectionGroupCommand);\r\n this._store.state.isResizing = false;\r\n this._store.rerender();\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -7,87 +7,95 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
7
7
  this.initialRotation = 0;
8
8
  this.rotation = 0;
9
9
  }
10
- handleMouseDown(event) {
11
- if (KritzelEventHelper.isLeftClick(event)) {
12
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
10
+ handlePointerDown(event) {
11
+ if (event.pointerType === 'mouse') {
12
+ if (KritzelEventHelper.isLeftClick(event)) {
13
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
14
+ const clientX = event.clientX - this._store.offsetX;
15
+ const clientY = event.clientY - this._store.offsetY;
16
+ this._store.state.isRotating = true;
17
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
18
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
19
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
20
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
21
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
22
+ }
23
+ }
24
+ }
25
+ if (event.pointerType === 'touch') {
26
+ const activePointers = Array.from(this._store.state.pointers.values());
27
+ const firstTouch = activePointers[0];
28
+ if (!firstTouch) {
29
+ return;
30
+ }
31
+ if (activePointers.length === 1) {
32
+ if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
33
+ const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
34
+ const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
35
+ this._store.state.isRotating = true;
36
+ const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
37
+ const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
38
+ const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
39
+ const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
40
+ this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
41
+ clearTimeout(this._store.state.longTouchTimeout);
42
+ }
43
+ }
44
+ }
45
+ }
46
+ handlePointerMove(event) {
47
+ if (event.pointerType === 'mouse') {
48
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
13
49
  const clientX = event.clientX - this._store.offsetX;
14
50
  const clientY = event.clientY - this._store.offsetY;
15
- this._store.state.isRotating = true;
16
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
17
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
51
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
52
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
18
53
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
19
54
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
20
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
55
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
56
+ this.rotation = currentRotation - this.initialRotation;
57
+ this._store.state.selectionGroup.rotate(this.rotation);
58
+ this._store.rerender();
21
59
  }
22
60
  }
23
- }
24
- handleMouseMove(event) {
25
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
26
- const clientX = event.clientX - this._store.offsetX;
27
- const clientY = event.clientY - this._store.offsetY;
28
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
29
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
30
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
31
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
32
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
33
- this.rotation = currentRotation - this.initialRotation;
34
- this._store.state.selectionGroup.rotate(this.rotation);
35
- this._store.rerender();
36
- }
37
- }
38
- handleMouseUp(_event) {
39
- if (this._store.state.isRotating) {
40
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
41
- this._store.state.isRotating = false;
42
- this.initialRotation = 0;
43
- this.rotation = 0;
44
- }
45
- }
46
- handleTouchStart(event) {
47
- const firstTouch = event.touches[0];
48
- if (!firstTouch) {
49
- return;
50
- }
51
- if (this._store.state.touchCount === 1) {
52
- if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {
61
+ if (event.pointerType === 'touch') {
62
+ const activePointers = Array.from(this._store.state.pointers.values());
63
+ const firstTouch = activePointers[0];
64
+ if (!firstTouch) {
65
+ return;
66
+ }
67
+ if (this._store.state.isRotating && this._store.state.selectionGroup) {
53
68
  const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
54
69
  const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
55
- this._store.state.isRotating = true;
56
- const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
57
- const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
70
+ const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
71
+ const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
58
72
  const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
59
73
  const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
60
- this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;
74
+ const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
75
+ this.rotation = currentRotation - this.initialRotation;
76
+ this._store.state.selectionGroup.rotate(this.rotation);
77
+ this._store.rerender();
61
78
  clearTimeout(this._store.state.longTouchTimeout);
62
79
  }
63
80
  }
64
81
  }
65
- handleTouchMove(event) {
66
- const firstTouch = event.touches[0];
67
- if (!firstTouch) {
68
- return;
69
- }
70
- if (this._store.state.isRotating && this._store.state.selectionGroup) {
71
- const clientX = Math.round(firstTouch.clientX - this._store.offsetX);
72
- const clientY = Math.round(firstTouch.clientY - this._store.offsetY);
73
- const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;
74
- const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;
75
- const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;
76
- const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;
77
- const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
78
- this.rotation = currentRotation - this.initialRotation;
79
- this._store.state.selectionGroup.rotate(this.rotation);
80
- this._store.rerender();
81
- clearTimeout(this._store.state.longTouchTimeout);
82
+ handlePointerUp(event) {
83
+ if (event.pointerType === 'mouse') {
84
+ if (this._store.state.isRotating) {
85
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
86
+ this._store.state.isRotating = false;
87
+ this.initialRotation = 0;
88
+ this.rotation = 0;
89
+ }
82
90
  }
83
- }
84
- handleTouchEnd(_event) {
85
- if (this._store.state.isRotating) {
86
- this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
87
- this._store.state.isRotating = false;
88
- this.initialRotation = 0;
89
- this.rotation = 0;
90
- clearTimeout(this._store.state.longTouchTimeout);
91
+ if (event.pointerType === 'touch') {
92
+ if (this._store.state.isRotating) {
93
+ this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));
94
+ this._store.state.isRotating = false;
95
+ this.initialRotation = 0;
96
+ this.rotation = 0;
97
+ clearTimeout(this._store.state.longTouchTimeout);
98
+ }
91
99
  }
92
100
  }
93
101
  }
@@ -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;AAEhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAK5D,YAAY,KAAmB;QAC7B,KAAK,CAAC,KAAK,CAAC,CAAC;QALf,oBAAe,GAAW,CAAC,CAAC;QAE5B,aAAQ,GAAW,CAAC,CAAC;IAIrB,CAAC;IAED,eAAe,CAAC,KAAiB;QAC/B,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE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AM,CAAC,QAAQ,EAAE,CAAC;YAEvB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;IAED,cAAc,CAAC,MAAkB;QAC/B,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YACjC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;YAEtG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;YAErC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;YACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;YAElB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QACnD,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { RotateSelectionGroupCommand } from '../commands/rotate-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handleMouseDown(event: MouseEvent): void {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.isRotating = true;\r\n\r\n const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;\r\n }\r\n }\r\n }\r\n\r\n handleMouseMove(event: MouseEvent): void {\r\n if (this._store.state.isRotating && this._store.state.selectionGroup) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n\r\n const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._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._store.state.selectionGroup.rotate(this.rotation);\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n handleMouseUp(_event: MouseEvent): void {\r\n if (this._store.state.isRotating) {\r\n this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));\r\n\r\n this._store.state.isRotating = false;\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n }\r\n }\r\n\r\n handleTouchStart(event: TouchEvent): void {\r\n const firstTouch = event.touches[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._store.state.touchCount === 1) {\r\n if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n this._store.state.isRotating = true;\r\n\r\n const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handleTouchMove(event: TouchEvent): void {\r\n const firstTouch = event.touches[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._store.state.isRotating && this._store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\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._store.state.selectionGroup.rotate(this.rotation);\r\n\r\n this._store.rerender();\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n\r\n handleTouchEnd(_event: TouchEvent): void {\r\n if (this._store.state.isRotating) {\r\n this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));\r\n\r\n this._store.state.isRotating = false;\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\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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QAAQ,CAAC,CAAC,CAAC;gBAEtG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAErC,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;gBACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAElB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelStore } from '../store.class';\r\nimport { RotateSelectionGroupCommand } from '../commands/rotate-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\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._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.isRotating = true;\r\n\r\n const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._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._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n this._store.state.isRotating = true;\r\n\r\n const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;\r\n\r\n clearTimeout(this._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._store.state.isRotating && this._store.state.selectionGroup) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._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._store.state.selectionGroup.rotate(this.rotation);\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._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._store.state.isRotating && this._store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._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._store.state.selectionGroup.rotate(this.rotation);\r\n\r\n this._store.rerender();\r\n\r\n clearTimeout(this._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._store.state.isRotating) {\r\n this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));\r\n\r\n this._store.state.isRotating = false;\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isRotating) {\r\n this._store.history.executeCommand(new RotateSelectionGroupCommand(this._store, this, this.rotation));\r\n\r\n this._store.state.isRotating = false;\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}