kritzel-stencil 0.0.140 → 0.0.142

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 (217) hide show
  1. package/dist/cjs/{index-nzUNdMPh.js → index-DcTwXs_q.js} +47 -22
  2. package/dist/cjs/index-DcTwXs_q.js.map +1 -0
  3. package/dist/cjs/index-SaGfCHX3.js +16452 -0
  4. package/dist/cjs/index-SaGfCHX3.js.map +1 -0
  5. package/dist/cjs/index.cjs.js +1 -1
  6. package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
  7. package/dist/cjs/kritzel-color_22.cjs.entry.js +134 -96
  8. package/dist/cjs/loader.cjs.js +2 -2
  9. package/dist/cjs/stencil.cjs.js +3 -3
  10. package/dist/cjs/stencil.cjs.js.map +1 -1
  11. package/dist/collection/classes/commands/add-object.command.js +1 -0
  12. package/dist/collection/classes/commands/add-object.command.js.map +1 -1
  13. package/dist/collection/classes/commands/base.command.js +2 -0
  14. package/dist/collection/classes/commands/base.command.js.map +1 -1
  15. package/dist/collection/classes/commands/remove-object.command.js +1 -3
  16. package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
  17. package/dist/collection/classes/commands/update-object.command.js +2 -0
  18. package/dist/collection/classes/commands/update-object.command.js.map +1 -1
  19. package/dist/collection/classes/core/command-manager.class.js +51 -0
  20. package/dist/collection/classes/core/command-manager.class.js.map +1 -0
  21. package/dist/collection/classes/core/core.class.js +30 -14
  22. package/dist/collection/classes/core/core.class.js.map +1 -1
  23. package/dist/collection/classes/core/history.class.js +2 -40
  24. package/dist/collection/classes/core/history.class.js.map +1 -1
  25. package/dist/collection/classes/core/viewport.class.js +16 -5
  26. package/dist/collection/classes/core/viewport.class.js.map +1 -1
  27. package/dist/collection/classes/handlers/context-menu.handler.js +1 -1
  28. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  29. package/dist/collection/classes/handlers/key.handler.js +2 -2
  30. package/dist/collection/classes/handlers/key.handler.js.map +1 -1
  31. package/dist/collection/classes/handlers/move.handler.js +11 -6
  32. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  33. package/dist/collection/classes/handlers/resize.handler.js +29 -5
  34. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  35. package/dist/collection/classes/handlers/rotation.handler.js +2 -2
  36. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  37. package/dist/collection/classes/handlers/selection.handler.js +4 -4
  38. package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
  39. package/dist/collection/classes/objects/base-object.class.js +15 -14
  40. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  41. package/dist/collection/classes/objects/custom-element.class.js +7 -1
  42. package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
  43. package/dist/collection/classes/objects/text.class.js +189 -82
  44. package/dist/collection/classes/objects/text.class.js.map +1 -1
  45. package/dist/collection/classes/tools/brush-tool.class.js +2 -2
  46. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  47. package/dist/collection/classes/tools/eraser-tool.class.js +2 -2
  48. package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
  49. package/dist/collection/classes/tools/image-tool.class.js +1 -1
  50. package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
  51. package/dist/collection/classes/tools/selection-tool.class.js +2 -2
  52. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  53. package/dist/collection/classes/tools/text-tool.class.js +17 -13
  54. package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
  55. package/dist/collection/collection-manifest.json +2 -2
  56. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +0 -1
  57. package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -1
  58. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +4 -8
  59. package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
  60. package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +21 -8
  61. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +33 -37
  62. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  63. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -2
  64. package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -1
  65. package/dist/collection/components/shared/kritzel-color/kritzel-color.js +3 -3
  66. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +3 -4
  67. package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -1
  68. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +5 -6
  69. package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
  70. package/dist/collection/components/shared/kritzel-font/kritzel-font.js +3 -3
  71. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +2 -3
  72. package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -1
  73. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +2 -3
  74. package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
  75. package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js +5 -5
  76. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +0 -2
  77. package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
  78. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +0 -2
  79. package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -1
  80. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +5 -6
  81. package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
  82. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +4 -5
  83. package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
  84. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -2
  85. package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -1
  86. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +3 -4
  87. package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -1
  88. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +0 -2
  89. package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
  90. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +1 -2
  91. package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
  92. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +1 -2
  93. package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -1
  94. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +1 -3
  95. package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
  96. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +0 -2
  97. package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
  98. package/dist/collection/interfaces/object.interface.js.map +1 -1
  99. package/dist/components/index.js +3 -3
  100. package/dist/components/kritzel-brush-style.js +4 -4
  101. package/dist/components/kritzel-color-palette.js +1 -1
  102. package/dist/components/kritzel-color.js +1 -1
  103. package/dist/components/kritzel-context-menu.js +1 -1
  104. package/dist/components/kritzel-control-brush-config.js +1 -1
  105. package/dist/components/kritzel-control-text-config.js +1 -1
  106. package/dist/components/kritzel-controls.js +1 -1
  107. package/dist/components/kritzel-cursor-trail.js +1 -1
  108. package/dist/components/kritzel-dropdown.js +1 -1
  109. package/dist/components/kritzel-editor.js +25 -25
  110. package/dist/components/kritzel-engine.js +1 -1
  111. package/dist/components/kritzel-font-family.js +1 -1
  112. package/dist/components/kritzel-font-size.js +1 -1
  113. package/dist/components/kritzel-font.js +1 -1
  114. package/dist/components/kritzel-icon.js +1 -1
  115. package/dist/components/kritzel-menu-item.js +1 -1
  116. package/dist/components/kritzel-menu.js +1 -1
  117. package/dist/components/kritzel-portal.js +1 -1
  118. package/dist/components/kritzel-split-button.js +1 -1
  119. package/dist/components/kritzel-stroke-size.js +1 -1
  120. package/dist/components/kritzel-tooltip.js +1 -1
  121. package/dist/components/kritzel-utility-panel.js +1 -1
  122. package/dist/components/kritzel-workspace-manager.js +1 -1
  123. package/dist/components/{p-BQJhnpY3.js → p-BEKicPnH.js} +3 -3
  124. package/dist/components/{p-BQJhnpY3.js.map → p-BEKicPnH.js.map} +1 -1
  125. package/dist/components/{p-D6FeQRzi.js → p-BFNwskCY.js} +4 -4
  126. package/dist/components/{p-D6FeQRzi.js.map → p-BFNwskCY.js.map} +1 -1
  127. package/dist/components/{p-sHDCqDbD.js → p-BJbN3vca.js} +6 -6
  128. package/dist/components/{p-sHDCqDbD.js.map → p-BJbN3vca.js.map} +1 -1
  129. package/dist/components/{p-bC64Ng59.js → p-ByAzDzS5.js} +3 -3
  130. package/dist/components/{p-bC64Ng59.js.map → p-ByAzDzS5.js.map} +1 -1
  131. package/dist/components/{p-CE_sOMS2.js → p-BycHaC-9.js} +4 -4
  132. package/dist/components/{p-CE_sOMS2.js.map → p-BycHaC-9.js.map} +1 -1
  133. package/dist/components/{p-SKH0G2nM.js → p-C8calcQF.js} +17 -17
  134. package/dist/components/{p-SKH0G2nM.js.map → p-C8calcQF.js.map} +1 -1
  135. package/dist/components/{p-BYanlgdq.js → p-C9hrbrUN.js} +27 -14
  136. package/dist/components/p-C9hrbrUN.js.map +1 -0
  137. package/dist/components/{p-JYqCBcMd.js → p-CEn1WeG3.js} +8 -8
  138. package/dist/components/{p-JYqCBcMd.js.map → p-CEn1WeG3.js.map} +1 -1
  139. package/dist/components/{p-C7UWRUAy.js → p-CGb-8cK4.js} +3 -3
  140. package/dist/components/{p-C7UWRUAy.js.map → p-CGb-8cK4.js.map} +1 -1
  141. package/dist/components/p-CZk591FE.js +14739 -0
  142. package/dist/components/p-CZk591FE.js.map +1 -0
  143. package/dist/components/{p-BJZudenH.js → p-C_hSH2nN.js} +3 -3
  144. package/dist/components/{p-BJZudenH.js.map → p-C_hSH2nN.js.map} +1 -1
  145. package/dist/components/{p-D2eJXNMx.js → p-CieOx1XL.js} +4 -4
  146. package/dist/components/{p-D2eJXNMx.js.map → p-CieOx1XL.js.map} +1 -1
  147. package/dist/components/{p-BFLXutiB.js → p-Co5lU_7h.js} +10 -10
  148. package/dist/components/{p-BFLXutiB.js.map → p-Co5lU_7h.js.map} +1 -1
  149. package/dist/components/{p-BV5iL9W6.js → p-CziwfEQh.js} +253 -181
  150. package/dist/components/p-CziwfEQh.js.map +1 -0
  151. package/dist/components/{p-sq9jgfX0.js → p-D27d2rKT.js} +3 -3
  152. package/dist/components/{p-sq9jgfX0.js.map → p-D27d2rKT.js.map} +1 -1
  153. package/dist/components/{p-DFO-6kuA.js → p-DPxzgBs0.js} +3 -3
  154. package/dist/components/{p-DFO-6kuA.js.map → p-DPxzgBs0.js.map} +1 -1
  155. package/dist/components/{p-vNnVlsJt.js → p-D_RcVGj0.js} +4 -4
  156. package/dist/components/{p-vNnVlsJt.js.map → p-D_RcVGj0.js.map} +1 -1
  157. package/dist/components/{p-C-ozL_Es.js → p-DqsgZIHC.js} +4 -4
  158. package/dist/components/{p-C-ozL_Es.js.map → p-DqsgZIHC.js.map} +1 -1
  159. package/dist/components/{p-Dh61W3GT.js → p-DzyZA2GT.js} +5 -5
  160. package/dist/components/{p-Dh61W3GT.js.map → p-DzyZA2GT.js.map} +1 -1
  161. package/dist/components/{p-DbmQ5DrU.js → p-dcR2uxM3.js} +5 -5
  162. package/dist/components/{p-DbmQ5DrU.js.map → p-dcR2uxM3.js.map} +1 -1
  163. package/dist/components/{p-BLc8TzcU.js → p-fiFoOjv0.js} +7 -7
  164. package/dist/components/{p-BLc8TzcU.js.map → p-fiFoOjv0.js.map} +1 -1
  165. package/dist/components/{p-IgPm36bH.js → p-gCHmJzc2.js} +4 -4
  166. package/dist/components/{p-IgPm36bH.js.map → p-gCHmJzc2.js.map} +1 -1
  167. package/dist/esm/{index-oCOlsFCN.js → index-Cw77zP6g.js} +47 -22
  168. package/dist/esm/index-Cw77zP6g.js.map +1 -0
  169. package/dist/esm/index-SIM_s7ed.js +16424 -0
  170. package/dist/esm/index-SIM_s7ed.js.map +1 -0
  171. package/dist/esm/index.js +1 -1
  172. package/dist/esm/kritzel-brush-style.entry.js +1 -1
  173. package/dist/esm/kritzel-color_22.entry.js +134 -96
  174. package/dist/esm/loader.js +3 -3
  175. package/dist/esm/stencil.js +4 -4
  176. package/dist/esm/stencil.js.map +1 -1
  177. package/dist/stencil/index.esm.js +1 -1
  178. package/dist/stencil/{p-25d1e040.entry.js → p-8b831c94.entry.js} +2 -2
  179. package/dist/stencil/p-Cw77zP6g.js +3 -0
  180. package/dist/stencil/p-Cw77zP6g.js.map +1 -0
  181. package/dist/stencil/p-SIM_s7ed.js +2 -0
  182. package/dist/stencil/p-SIM_s7ed.js.map +1 -0
  183. package/dist/stencil/p-b697b2c1.entry.js +2 -0
  184. package/dist/stencil/p-b697b2c1.entry.js.map +1 -0
  185. package/dist/stencil/stencil.esm.js +1 -1
  186. package/dist/stencil/stencil.esm.js.map +1 -1
  187. package/dist/types/classes/commands/add-object.command.d.ts +2 -2
  188. package/dist/types/classes/commands/base.command.d.ts +2 -1
  189. package/dist/types/classes/commands/remove-object.command.d.ts +2 -2
  190. package/dist/types/classes/commands/update-object.command.d.ts +2 -2
  191. package/dist/types/classes/core/command-manager.class.d.ts +16 -0
  192. package/dist/types/classes/core/core.class.d.ts +4 -0
  193. package/dist/types/classes/core/history.class.d.ts +0 -8
  194. package/dist/types/classes/core/viewport.class.d.ts +2 -0
  195. package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
  196. package/dist/types/classes/objects/base-object.class.d.ts +6 -4
  197. package/dist/types/classes/objects/text.class.d.ts +33 -12
  198. package/dist/types/interfaces/object.interface.d.ts +1 -3
  199. package/dist/types/stencil-public-runtime.d.ts +36 -12
  200. package/package.json +7 -2
  201. package/dist/cjs/index-Clh2g9JM.js +0 -2850
  202. package/dist/cjs/index-Clh2g9JM.js.map +0 -1
  203. package/dist/cjs/index-nzUNdMPh.js.map +0 -1
  204. package/dist/components/p-BV5iL9W6.js.map +0 -1
  205. package/dist/components/p-BYanlgdq.js.map +0 -1
  206. package/dist/components/p-C5sTCwe3.js +0 -1171
  207. package/dist/components/p-C5sTCwe3.js.map +0 -1
  208. package/dist/esm/index-BAbkwyRx.js +0 -2822
  209. package/dist/esm/index-BAbkwyRx.js.map +0 -1
  210. package/dist/esm/index-oCOlsFCN.js.map +0 -1
  211. package/dist/stencil/p-BAbkwyRx.js +0 -2
  212. package/dist/stencil/p-BAbkwyRx.js.map +0 -1
  213. package/dist/stencil/p-fe465059.entry.js +0 -2
  214. package/dist/stencil/p-fe465059.entry.js.map +0 -1
  215. package/dist/stencil/p-oCOlsFCN.js +0 -3
  216. package/dist/stencil/p-oCOlsFCN.js.map +0 -1
  217. /package/dist/stencil/{p-25d1e040.entry.js.map → p-8b831c94.entry.js.map} +0 -0
@@ -4,47 +4,24 @@ export class KritzelHistory {
4
4
  _core;
5
5
  undoStack;
6
6
  redoStack;
7
- previousViewport;
8
7
  constructor(core) {
9
8
  this._core = core;
10
9
  this.undoStack = new KritzelCircularBuffer(this._core.store.state.historyBufferSize);
11
10
  this.redoStack = new KritzelCircularBuffer(this._core.store.state.historyBufferSize);
12
- this.previousViewport = {
13
- scale: this._core.store.state.scale,
14
- scaleStep: this._core.store.state.scaleStep,
15
- translateX: this._core.store.state.translateX,
16
- translateY: this._core.store.state.translateY,
17
- };
18
11
  }
19
12
  reset() {
20
13
  this.undoStack.clear();
21
14
  this.redoStack.clear();
22
- this.previousViewport = {
15
+ this._core.commandManager.previousViewport = {
23
16
  scale: this._core.store.state.scale,
24
17
  scaleStep: this._core.store.state.scaleStep,
25
18
  translateX: this._core.store.state.translateX,
26
19
  translateY: this._core.store.state.translateY
27
20
  };
28
21
  }
29
- executeCommand(command) {
30
- if (this._core.store.state.hasViewportChanged) {
31
- this.addUpdateViewportCommand();
32
- }
33
- command.execute();
34
- if (command.skipHistory === false) {
35
- if (this._core.store.state.debugInfo.logCommands) {
36
- console.info('add', command);
37
- }
38
- this.undoStack.add(command);
39
- if (this.redoStack.isEmpty() === false) {
40
- this.redoStack.clear();
41
- }
42
- }
43
- this._core.rerender();
44
- }
45
22
  undo() {
46
23
  if (this._core.store.state.hasViewportChanged) {
47
- const command = new UpdateViewportCommand(this._core, this, this.previousViewport);
24
+ const command = new UpdateViewportCommand(this._core, this, this._core.commandManager.previousViewport);
48
25
  command.undo();
49
26
  this._core.store.state.hasViewportChanged = false;
50
27
  this._core.rerender();
@@ -70,20 +47,5 @@ export class KritzelHistory {
70
47
  }
71
48
  this._core.rerender();
72
49
  }
73
- addUpdateViewportCommand() {
74
- const command = new UpdateViewportCommand(this._core, this, this.previousViewport);
75
- command.execute();
76
- this.undoStack.add(command);
77
- if (this.redoStack.isEmpty() === false) {
78
- this.redoStack.clear();
79
- }
80
- this._core.store.state.hasViewportChanged = false;
81
- this.previousViewport = {
82
- scale: this._core.store.state.scale,
83
- scaleStep: this._core.store.state.scaleStep,
84
- translateX: this._core.store.state.translateX,
85
- translateY: this._core.store.state.translateY,
86
- };
87
- }
88
50
  }
89
51
  //# sourceMappingURL=history.class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"history.class.js","sourceRoot":"","sources":["../../../src/classes/core/history.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,MAAM,OAAO,cAAc;IACR,KAAK,CAAc;IAEpC,SAAS,CAA4C;IACrD,SAAS,CAA4C;IAErD,gBAAgB,CAKd;IAEF,YAAY,IAAiB;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAqB,CAAqB,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AAC,KAAK,CAAC,UAAU;SAC9C,CAAC;IACJ,CAAC;CACF","sourcesContent":["import { KritzelBaseCommand } from '../commands/base.command';\r\nimport { UpdateViewportCommand } from '../commands/update-viewport.command';\r\nimport { KritzelCore } from './core.class';\r\nimport { KritzelCircularBuffer } from '../structures/circular-buffer.structure';\r\n\r\nexport class KritzelHistory {\r\n private readonly _core: KritzelCore;\r\n\r\n undoStack: KritzelCircularBuffer<KritzelBaseCommand>;\r\n redoStack: KritzelCircularBuffer<KritzelBaseCommand>;\r\n\r\n previousViewport: {\r\n scale: number;\r\n scaleStep: number;\r\n translateX: number;\r\n translateY: number;\r\n };\r\n\r\n constructor(core: KritzelCore) {\r\n this._core = core;\r\n this.undoStack = new KritzelCircularBuffer<KritzelBaseCommand>(this._core.store.state.historyBufferSize);\r\n this.redoStack = new KritzelCircularBuffer<KritzelBaseCommand>(this._core.store.state.historyBufferSize);\r\n this.previousViewport = {\r\n scale: this._core.store.state.scale,\r\n scaleStep: this._core.store.state.scaleStep,\r\n translateX: this._core.store.state.translateX,\r\n translateY: this._core.store.state.translateY,\r\n };\r\n }\r\n\r\n reset() {\r\n this.undoStack.clear();\r\n this.redoStack.clear();\r\n this.previousViewport = {\r\n scale: this._core.store.state.scale,\r\n scaleStep: this._core.store.state.scaleStep,\r\n translateX: this._core.store.state.translateX,\r\n translateY: this._core.store.state.translateY\r\n };\r\n }\r\n\r\n executeCommand(command: KritzelBaseCommand) {\r\n if (this._core.store.state.hasViewportChanged) {\r\n this.addUpdateViewportCommand();\r\n }\r\n\r\n command.execute();\r\n\r\n if (command.skipHistory === false) {\r\n if (this._core.store.state.debugInfo.logCommands) {\r\n console.info('add', command);\r\n }\r\n\r\n this.undoStack.add(command);\r\n\r\n if (this.redoStack.isEmpty() === false) {\r\n this.redoStack.clear();\r\n }\r\n }\r\n\r\n this._core.rerender();\r\n }\r\n\r\n undo() {\r\n if (this._core.store.state.hasViewportChanged) {\r\n const command = new UpdateViewportCommand(this._core, this, this.previousViewport);\r\n command.undo();\r\n this._core.store.state.hasViewportChanged = false;\r\n this._core.rerender();\r\n return;\r\n }\r\n\r\n const command = this.undoStack.pop();\r\n if (command) {\r\n command.undo();\r\n if (this._core.store.state.debugInfo.logCommands) console.info('undo', command);\r\n this.redoStack.add(command);\r\n }\r\n\r\n this._core.store.state.copiedObjects = null;\r\n this._core.rerender();\r\n }\r\n\r\n redo() {\r\n const command = this.redoStack.pop();\r\n if (command) {\r\n command.execute();\r\n if (this._core.store.state.debugInfo.logCommands) console.info('redo', command);\r\n this.undoStack.add(command);\r\n }\r\n\r\n this._core.rerender();\r\n }\r\n\r\n private addUpdateViewportCommand() {\r\n const command = new UpdateViewportCommand(this._core, this, this.previousViewport);\r\n command.execute();\r\n this.undoStack.add(command);\r\n\r\n if (this.redoStack.isEmpty() === false) {\r\n this.redoStack.clear();\r\n }\r\n\r\n this._core.store.state.hasViewportChanged = false;\r\n this.previousViewport = {\r\n scale: this._core.store.state.scale,\r\n scaleStep: this._core.store.state.scaleStep,\r\n translateX: this._core.store.state.translateX,\r\n translateY: this._core.store.state.translateY,\r\n };\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"history.class.js","sourceRoot":"","sources":["../../../src/classes/core/history.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AAEhF,MAAM,OAAO,cAAc;IACR,KAAK,CAAc;IAEpC,SAAS,CAA4C;IACrD,SAAS,CAA4C;IAIrD,YAAY,IAAiB;QAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAqB,CAAqB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACzG,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAqB,CAAqB,IAAI,CAAC,KAAK,CAAC,KAAK,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AAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;IAED,IAAI;QACF,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QACrC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,OAAO,EAAE,CAAC;YAClB,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,WAAW;gBAAE,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAChF,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC9B,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACxB,CAAC;CACF","sourcesContent":["import { KritzelBaseCommand } from '../commands/base.command';\r\nimport { UpdateViewportCommand } from '../commands/update-viewport.command';\r\nimport { KritzelCore } from './core.class';\r\nimport { KritzelCircularBuffer } from '../structures/circular-buffer.structure';\r\n\r\nexport class KritzelHistory {\r\n private readonly _core: KritzelCore;\r\n\r\n undoStack: KritzelCircularBuffer<KritzelBaseCommand>;\r\n redoStack: KritzelCircularBuffer<KritzelBaseCommand>;\r\n\r\n \r\n\r\n constructor(core: KritzelCore) {\r\n this._core = core;\r\n this.undoStack = new KritzelCircularBuffer<KritzelBaseCommand>(this._core.store.state.historyBufferSize);\r\n this.redoStack = new KritzelCircularBuffer<KritzelBaseCommand>(this._core.store.state.historyBufferSize);\r\n }\r\n\r\n reset() {\r\n this.undoStack.clear();\r\n this.redoStack.clear();\r\n this._core.commandManager.previousViewport = {\r\n scale: this._core.store.state.scale,\r\n scaleStep: this._core.store.state.scaleStep,\r\n translateX: this._core.store.state.translateX,\r\n translateY: this._core.store.state.translateY\r\n };\r\n }\r\n\r\n\r\n undo() {\r\n if (this._core.store.state.hasViewportChanged) {\r\n const command = new UpdateViewportCommand(this._core, this, this._core.commandManager.previousViewport);\r\n command.undo();\r\n this._core.store.state.hasViewportChanged = false;\r\n this._core.rerender();\r\n return;\r\n }\r\n\r\n const command = this.undoStack.pop();\r\n if (command) {\r\n command.undo();\r\n if (this._core.store.state.debugInfo.logCommands) console.info('undo', command);\r\n this.redoStack.add(command);\r\n }\r\n\r\n this._core.store.state.copiedObjects = null;\r\n this._core.rerender();\r\n }\r\n\r\n redo() {\r\n const command = this.redoStack.pop();\r\n if (command) {\r\n command.execute();\r\n if (this._core.store.state.debugInfo.logCommands) console.info('redo', command);\r\n this.undoStack.add(command);\r\n }\r\n\r\n this._core.rerender();\r\n }\r\n}\r\n"]}
@@ -2,6 +2,7 @@ import { KritzelMouseButton } from "../../enums/event-button.enum";
2
2
  import { KritzelEventHelper } from "../../helpers/event.helper";
3
3
  export class KritzelViewport {
4
4
  _core;
5
+ _debounceUpdate;
5
6
  initialTouchDistance = 0;
6
7
  startX = 0;
7
8
  startY = 0;
@@ -14,6 +15,16 @@ export class KritzelViewport {
14
15
  this._core.store.state.startY = 0;
15
16
  this._core.store.state.translateX = 0;
16
17
  this._core.store.state.translateY = 0;
18
+ this._debounceUpdate = this.debounce(() => {
19
+ this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
20
+ }, 0);
21
+ }
22
+ debounce(func, delay) {
23
+ let timeoutId;
24
+ return () => {
25
+ clearTimeout(timeoutId);
26
+ timeoutId = setTimeout(func, delay);
27
+ };
17
28
  }
18
29
  handleResize() {
19
30
  this._core.store.state.viewportWidth = this._core.store.state.host.clientWidth;
@@ -64,7 +75,7 @@ export class KritzelViewport {
64
75
  this._core.store.state.hasViewportChanged = true;
65
76
  this._core.store.state.skipContextMenu = true;
66
77
  this._core.rerender();
67
- this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
78
+ this._debounceUpdate();
68
79
  }
69
80
  }
70
81
  if (event.pointerType === 'touch') {
@@ -100,7 +111,7 @@ export class KritzelViewport {
100
111
  this.startY = midpointY;
101
112
  this._core.store.state.hasViewportChanged = true;
102
113
  this._core.rerender();
103
- this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
114
+ this._debounceUpdate();
104
115
  }
105
116
  }
106
117
  }
@@ -134,7 +145,7 @@ export class KritzelViewport {
134
145
  this._core.store.state.translateY = viewportHeight / 2 - objectCenterY * scale;
135
146
  this._core.store.state.hasViewportChanged = true;
136
147
  this._core.rerender();
137
- this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
148
+ this._debounceUpdate();
138
149
  }
139
150
  centerFitInViewport(object) {
140
151
  const scaleX = this._core.store.state.viewportWidth / (object.rotatedBoundingBox.width * 1.1);
@@ -161,7 +172,7 @@ export class KritzelViewport {
161
172
  this._core.store.state.translateY = this._core.store.state.translateY - translateYAdjustment;
162
173
  this._core.store.state.hasViewportChanged = true;
163
174
  this._core.rerender();
164
- this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
175
+ this._debounceUpdate();
165
176
  setTimeout(() => {
166
177
  this._core.store.state.isScaling = false;
167
178
  }, 300);
@@ -172,7 +183,7 @@ export class KritzelViewport {
172
183
  this._core.store.state.translateY = this._core.store.state.translateY - event.deltaY * panSpeed;
173
184
  this._core.store.state.hasViewportChanged = true;
174
185
  this._core.rerender();
175
- this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);
186
+ this._debounceUpdate();
176
187
  }
177
188
  }
178
189
  //# sourceMappingURL=viewport.class.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"viewport.class.js","sourceRoot":"","sources":["../../../src/classes/core/viewport.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,k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ums/event-button.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelCore } from './core.class';\r\n\r\nexport class KritzelViewport {\r\n private readonly _core: KritzelCore;\r\n\r\n initialTouchDistance: number = 0;\r\n startX: number = 0;\r\n startY: number = 0;\r\n\r\n constructor(core: KritzelCore, host: HTMLElement) {\r\n this._core = core;\r\n this._core.store.state.host = host;\r\n this._core.store.state.viewportWidth = host.clientWidth;\r\n this._core.store.state.viewportHeight = host.clientHeight;\r\n this._core.store.state.startX = 0;\r\n this._core.store.state.startY = 0;\r\n this._core.store.state.translateX = 0;\r\n this._core.store.state.translateY = 0;\r\n }\r\n\r\n handleResize(): void {\r\n this._core.store.state.viewportWidth = this._core.store.state.host.clientWidth;\r\n this._core.store.state.viewportHeight = this._core.store.state.host.clientHeight;\r\n this._core.store.state.hasViewportChanged = true;\r\n this._core.rerender();\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const adjustedClientX = event.clientX - this._core.store.offsetX;\r\n const adjustedClientY = event.clientY - this._core.store.offsetY;\r\n\r\n if (event.button === KritzelMouseButton.Right) {\r\n this._core.store.state.isPanning = true;\r\n this._core.store.state.startX = adjustedClientX;\r\n this._core.store.state.startY = adjustedClientY;\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 (activePointers.length === 2) {\r\n this._core.store.state.currentPath = null;\r\n this._core.store.state.isScaling = true;\r\n\r\n const firstTouchX = activePointers[0].clientX - this._core.store.offsetX;\r\n const firstTouchY = activePointers[0].clientY - this._core.store.offsetY;\r\n\r\n const secondTouchX = activePointers[1].clientX - this._core.store.offsetX;\r\n const secondTouchY = activePointers[1].clientY - this._core.store.offsetY;\r\n\r\n this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));\r\n\r\n this.startX = (firstTouchX + secondTouchX) / 2;\r\n this.startY = (firstTouchY + secondTouchY) / 2;\r\n this._core.rerender();\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const hostRect = this._core.store.state.host.getBoundingClientRect();\r\n const xRelativeToHost = event.clientX - hostRect.left;\r\n const yRelativeToHost = event.clientY - hostRect.top;\r\n\r\n this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;\r\n this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n if (this._core.store.state.isPanning) {\r\n const dx = xRelativeToHost - this._core.store.state.startX;\r\n const dy = yRelativeToHost - this._core.store.state.startY;\r\n\r\n this._core.store.state.translateX += dx;\r\n this._core.store.state.translateY += dy;\r\n this._core.store.state.startX = xRelativeToHost;\r\n this._core.store.state.startY = yRelativeToHost;\r\n this._core.store.state.hasViewportChanged = true;\r\n this._core.store.state.skipContextMenu = true;\r\n\r\n this._core.rerender();\r\n this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const hostRect = this._core.store.state.host.getBoundingClientRect();\r\n const xRelativeToHost = event.clientX - hostRect.left;\r\n const yRelativeToHost = event.clientY - hostRect.top;\r\n\r\n this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;\r\n this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (activePointers.length === 2) {\r\n const firstTouchX = activePointers[0].clientX - this._core.store.offsetX;\r\n const firstTouchY = activePointers[0].clientY - this._core.store.offsetY;\r\n\r\n const secondTouchX = activePointers[1].clientX - this._core.store.offsetX;\r\n const secondTouchY = activePointers[1].clientY - this._core.store.offsetY;\r\n\r\n const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));\r\n\r\n const midpointX = (firstTouchX + secondTouchX) / 2;\r\n const midpointY = (firstTouchY + secondTouchY) / 2;\r\n\r\n const scaleRatio = currentTouchDistance / this.initialTouchDistance!;\r\n const newScale = this._core.store.state.scale * scaleRatio;\r\n\r\n if (newScale > this._core.store.state.scaleMax || newScale < this._core.store.state.scaleMin) {\r\n this._core.store.state.translateX = this._core.store.state.translateX + midpointX - this.startX;\r\n this._core.store.state.translateY = this._core.store.state.translateY + midpointY - this.startY;\r\n } else {\r\n const translateXAdjustment = (midpointX - this._core.store.state.translateX) * (scaleRatio - 1);\r\n const translateYAdjustment = (midpointY - this._core.store.state.translateY) * (scaleRatio - 1);\r\n\r\n this._core.store.state.translateX = this._core.store.state.translateX + midpointX - this.startX - translateXAdjustment;\r\n this._core.store.state.translateY = this._core.store.state.translateY + midpointY - this.startY - translateYAdjustment;\r\n this._core.store.state.scale = newScale;\r\n\r\n this.initialTouchDistance = currentTouchDistance;\r\n }\r\n\r\n this.startX = midpointX;\r\n this.startY = midpointY;\r\n\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);\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.isPanning) {\r\n this._core.store.state.isPanning = false;\r\n this._core.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n this._core.store.state.isScaling = false;\r\n this._core.rerender();\r\n }\r\n }\r\n\r\n handleWheel(event: WheelEvent): void {\r\n event.preventDefault();\r\n\r\n if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {\r\n this.handleZoom(event);\r\n }\r\n\r\n if (!event.ctrlKey) {\r\n this.handlePan(event);\r\n }\r\n }\r\n\r\n centerInViewport(object: KritzelBaseObject): void {\r\n const { scale, viewportWidth, viewportHeight } = this._core.store.state;\r\n const { x, y, width, height } = object.rotatedBoundingBox;\r\n\r\n const objectCenterX = x + width / 2;\r\n const objectCenterY = y + height / 2;\r\n\r\n this._core.store.state.translateX = viewportWidth / 2 - objectCenterX * scale;\r\n this._core.store.state.translateY = viewportHeight / 2 - objectCenterY * scale;\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);\r\n }\r\n\r\n centerFitInViewport(object: KritzelBaseObject): void {\r\n const scaleX = this._core.store.state.viewportWidth / (object.rotatedBoundingBox.width * 1.1);\r\n const scaleY = this._core.store.state.viewportHeight / (object.rotatedBoundingBox.height * 1.1);\r\n const newScale = Math.min(scaleX, scaleY, this._core.store.state.scaleMax);\r\n const clampedScale = Math.max(newScale, this._core.store.state.scaleMin);\r\n \r\n this._core.store.state.scale = clampedScale;\r\n this.centerInViewport(object);\r\n }\r\n\r\n private handleZoom(event: WheelEvent): void {\r\n this._core.store.state.isScaling = true;\r\n const rect = this._core.store.state.host.getBoundingClientRect();\r\n const xRelativeToHost = event.clientX - rect.left;\r\n const yRelativeToHost = event.clientY - rect.top;\r\n\r\n this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;\r\n this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const delta = event.deltaY > 0 ? -this._core.store.state.scaleStep * this._core.store.state.scale : this._core.store.state.scaleStep * this._core.store.state.scale;\r\n const newScale = Math.min(this._core.store.state.scaleMax, Math.max(this._core.store.state.scaleMin, this._core.store.state.scale + delta));\r\n\r\n const scaleRatio = newScale / this._core.store.state.scale;\r\n const translateXAdjustment = (xRelativeToHost - this._core.store.state.translateX) * (scaleRatio - 1);\r\n const translateYAdjustment = (yRelativeToHost - this._core.store.state.translateY) * (scaleRatio - 1);\r\n\r\n this._core.store.state.scale = newScale;\r\n\r\n this._core.store.state.translateX = this._core.store.state.translateX - translateXAdjustment;\r\n this._core.store.state.translateY = this._core.store.state.translateY - translateYAdjustment;\r\n\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);\r\n\r\n setTimeout(() => {\r\n this._core.store.state.isScaling = false;\r\n }, 300);\r\n }\r\n\r\n private handlePan(event: WheelEvent): void {\r\n const panSpeed = 0.8;\r\n\r\n this._core.store.state.translateX = this._core.store.state.translateX - event.deltaX * panSpeed;\r\n this._core.store.state.translateY = this._core.store.state.translateY - event.deltaY * panSpeed;\r\n\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"viewport.class.js","sourceRoot":"","sources":["../../../src/classes/core/viewport.class.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,MAAM,OAAO,eAAe;IACT,KAAK,CAAc;IACnB,eAAe,CAAa;IAE7C,oBAAoB,GAAW,CAAC,CAAC;IACjC,MAAM,GAAW,CAAC,CAAC;IACnB,MAAM,GAAW,CAAC,CAAC;IAEnB,YAAY,IAAiB,EAAE,IAAiB;QAC9C,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,CAAC;QACxD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,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KAAK,CAAC,MAAM,GAAG,QAAQ,CAAC;QAEhG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,kBAAkB,GAAG,IAAI,CAAC;QAEjD,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;CACF","sourcesContent":["import { KritzelBaseObject } from '../..';\r\nimport { KritzelMouseButton } from '../../enums/event-button.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { KritzelCore } from './core.class';\r\n\r\nexport class KritzelViewport {\r\n private readonly _core: KritzelCore;\r\n private readonly _debounceUpdate: () => void;\r\n\r\n initialTouchDistance: number = 0;\r\n startX: number = 0;\r\n startY: number = 0;\r\n\r\n constructor(core: KritzelCore, host: HTMLElement) {\r\n this._core = core;\r\n this._core.store.state.host = host;\r\n this._core.store.state.viewportWidth = host.clientWidth;\r\n this._core.store.state.viewportHeight = host.clientHeight;\r\n this._core.store.state.startX = 0;\r\n this._core.store.state.startY = 0;\r\n this._core.store.state.translateX = 0;\r\n this._core.store.state.translateY = 0;\r\n\r\n this._debounceUpdate = this.debounce(() => {\r\n this._core.updateWorkspaceViewport(this._core.store.state.translateX, this._core.store.state.translateY, this._core.store.state.scale);\r\n }, 0);\r\n }\r\n\r\n private debounce(func: () => void, delay: number): () => void {\r\n let timeoutId: ReturnType<typeof setTimeout>;\r\n return () => {\r\n clearTimeout(timeoutId);\r\n timeoutId = setTimeout(func, delay);\r\n };\r\n }\r\n\r\n handleResize(): void {\r\n this._core.store.state.viewportWidth = this._core.store.state.host.clientWidth;\r\n this._core.store.state.viewportHeight = this._core.store.state.host.clientHeight;\r\n this._core.store.state.hasViewportChanged = true;\r\n this._core.rerender();\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const adjustedClientX = event.clientX - this._core.store.offsetX;\r\n const adjustedClientY = event.clientY - this._core.store.offsetY;\r\n\r\n if (event.button === KritzelMouseButton.Right) {\r\n this._core.store.state.isPanning = true;\r\n this._core.store.state.startX = adjustedClientX;\r\n this._core.store.state.startY = adjustedClientY;\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 (activePointers.length === 2) {\r\n this._core.store.state.currentPath = null;\r\n this._core.store.state.isScaling = true;\r\n\r\n const firstTouchX = activePointers[0].clientX - this._core.store.offsetX;\r\n const firstTouchY = activePointers[0].clientY - this._core.store.offsetY;\r\n\r\n const secondTouchX = activePointers[1].clientX - this._core.store.offsetX;\r\n const secondTouchY = activePointers[1].clientY - this._core.store.offsetY;\r\n\r\n this.initialTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));\r\n\r\n this.startX = (firstTouchX + secondTouchX) / 2;\r\n this.startY = (firstTouchY + secondTouchY) / 2;\r\n this._core.rerender();\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n const hostRect = this._core.store.state.host.getBoundingClientRect();\r\n const xRelativeToHost = event.clientX - hostRect.left;\r\n const yRelativeToHost = event.clientY - hostRect.top;\r\n\r\n this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;\r\n this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n if (this._core.store.state.isPanning) {\r\n const dx = xRelativeToHost - this._core.store.state.startX;\r\n const dy = yRelativeToHost - this._core.store.state.startY;\r\n\r\n this._core.store.state.translateX += dx;\r\n this._core.store.state.translateY += dy;\r\n this._core.store.state.startX = xRelativeToHost;\r\n this._core.store.state.startY = yRelativeToHost;\r\n this._core.store.state.hasViewportChanged = true;\r\n this._core.store.state.skipContextMenu = true;\r\n\r\n this._core.rerender();\r\n this._debounceUpdate();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const hostRect = this._core.store.state.host.getBoundingClientRect();\r\n const xRelativeToHost = event.clientX - hostRect.left;\r\n const yRelativeToHost = event.clientY - hostRect.top;\r\n\r\n this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;\r\n this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (activePointers.length === 2) {\r\n const firstTouchX = activePointers[0].clientX - this._core.store.offsetX;\r\n const firstTouchY = activePointers[0].clientY - this._core.store.offsetY;\r\n\r\n const secondTouchX = activePointers[1].clientX - this._core.store.offsetX;\r\n const secondTouchY = activePointers[1].clientY - this._core.store.offsetY;\r\n\r\n const currentTouchDistance = Math.sqrt(Math.pow(firstTouchX - secondTouchX, 2) + Math.pow(firstTouchY - secondTouchY, 2));\r\n\r\n const midpointX = (firstTouchX + secondTouchX) / 2;\r\n const midpointY = (firstTouchY + secondTouchY) / 2;\r\n\r\n const scaleRatio = currentTouchDistance / this.initialTouchDistance!;\r\n const newScale = this._core.store.state.scale * scaleRatio;\r\n\r\n if (newScale > this._core.store.state.scaleMax || newScale < this._core.store.state.scaleMin) {\r\n this._core.store.state.translateX = this._core.store.state.translateX + midpointX - this.startX;\r\n this._core.store.state.translateY = this._core.store.state.translateY + midpointY - this.startY;\r\n } else {\r\n const translateXAdjustment = (midpointX - this._core.store.state.translateX) * (scaleRatio - 1);\r\n const translateYAdjustment = (midpointY - this._core.store.state.translateY) * (scaleRatio - 1);\r\n\r\n this._core.store.state.translateX = this._core.store.state.translateX + midpointX - this.startX - translateXAdjustment;\r\n this._core.store.state.translateY = this._core.store.state.translateY + midpointY - this.startY - translateYAdjustment;\r\n this._core.store.state.scale = newScale;\r\n\r\n this.initialTouchDistance = currentTouchDistance;\r\n }\r\n\r\n this.startX = midpointX;\r\n this.startY = midpointY;\r\n\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._debounceUpdate();\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.isPanning) {\r\n this._core.store.state.isPanning = false;\r\n this._core.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n this._core.store.state.isScaling = false;\r\n this._core.rerender();\r\n }\r\n }\r\n\r\n handleWheel(event: WheelEvent): void {\r\n event.preventDefault();\r\n\r\n if (event.ctrlKey === true && KritzelEventHelper.isMainMouseWheel(event)) {\r\n this.handleZoom(event);\r\n }\r\n\r\n if (!event.ctrlKey) {\r\n this.handlePan(event);\r\n }\r\n }\r\n\r\n centerInViewport(object: KritzelBaseObject): void {\r\n const { scale, viewportWidth, viewportHeight } = this._core.store.state;\r\n const { x, y, width, height } = object.rotatedBoundingBox;\r\n\r\n const objectCenterX = x + width / 2;\r\n const objectCenterY = y + height / 2;\r\n\r\n this._core.store.state.translateX = viewportWidth / 2 - objectCenterX * scale;\r\n this._core.store.state.translateY = viewportHeight / 2 - objectCenterY * scale;\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._debounceUpdate();\r\n }\r\n\r\n centerFitInViewport(object: KritzelBaseObject): void {\r\n const scaleX = this._core.store.state.viewportWidth / (object.rotatedBoundingBox.width * 1.1);\r\n const scaleY = this._core.store.state.viewportHeight / (object.rotatedBoundingBox.height * 1.1);\r\n const newScale = Math.min(scaleX, scaleY, this._core.store.state.scaleMax);\r\n const clampedScale = Math.max(newScale, this._core.store.state.scaleMin);\r\n\r\n this._core.store.state.scale = clampedScale;\r\n this.centerInViewport(object);\r\n }\r\n\r\n private handleZoom(event: WheelEvent): void {\r\n this._core.store.state.isScaling = true;\r\n const rect = this._core.store.state.host.getBoundingClientRect();\r\n const xRelativeToHost = event.clientX - rect.left;\r\n const yRelativeToHost = event.clientY - rect.top;\r\n\r\n this._core.store.state.pointerX = (xRelativeToHost - this._core.store.state.translateX) / this._core.store.state.scale;\r\n this._core.store.state.pointerY = (yRelativeToHost - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const delta = event.deltaY > 0 ? -this._core.store.state.scaleStep * this._core.store.state.scale : this._core.store.state.scaleStep * this._core.store.state.scale;\r\n const newScale = Math.min(this._core.store.state.scaleMax, Math.max(this._core.store.state.scaleMin, this._core.store.state.scale + delta));\r\n\r\n const scaleRatio = newScale / this._core.store.state.scale;\r\n const translateXAdjustment = (xRelativeToHost - this._core.store.state.translateX) * (scaleRatio - 1);\r\n const translateYAdjustment = (yRelativeToHost - this._core.store.state.translateY) * (scaleRatio - 1);\r\n\r\n this._core.store.state.scale = newScale;\r\n\r\n this._core.store.state.translateX = this._core.store.state.translateX - translateXAdjustment;\r\n this._core.store.state.translateY = this._core.store.state.translateY - translateYAdjustment;\r\n\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._debounceUpdate();\r\n\r\n setTimeout(() => {\r\n this._core.store.state.isScaling = false;\r\n }, 300);\r\n }\r\n\r\n private handlePan(event: WheelEvent): void {\r\n const panSpeed = 0.8;\r\n\r\n this._core.store.state.translateX = this._core.store.state.translateX - event.deltaX * panSpeed;\r\n this._core.store.state.translateY = this._core.store.state.translateY - event.deltaY * panSpeed;\r\n\r\n this._core.store.state.hasViewportChanged = true;\r\n\r\n this._core.rerender();\r\n this._debounceUpdate();\r\n }\r\n}\r\n"]}
@@ -39,7 +39,7 @@ export class KritzelContextMenuHandler extends KritzelBaseHandler {
39
39
  new RemoveSelectionGroupCommand(this._core, this._core.store.state.selectionGroup),
40
40
  new AddSelectionGroupCommand(this._core, this, selectionGroup),
41
41
  ]);
42
- this._core.history.executeCommand(batch);
42
+ this._core.commandManager.executeCommand(batch);
43
43
  }
44
44
  this._core.store.state.contextMenuItems = this._core.store.state.selectionGroup ? this.objectContextMenuItems : this.globalContextMenuItems;
45
45
  let x = event.clientX - this._core.store.offsetX;
@@ -1 +1 @@
1
- {"version":3,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,GAAG,IAAI,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"]}
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;AACzD,OAAO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CAAC,KAAK,CAAC,OAAO,CAAC;QAEzD,MAAM,iBAAiB,GAAG,GAAG,CAAC;QAC9B,MAAM,kBAAkB,GAAG,GAAG,CAAC;QAC/B,MAAM,MAAM,GAAG,EAAE,CAAC;QAElB,IAAI,CAAC,GAAG,iBAAiB,GAAG,MAAM,CAAC,UAAU,GAAG,MAAM,EAAE,CAAC;YACvD,CAAC,GAAG,MAAM,CAAC,UAAU,GAAG,iBAAiB,GAAG,MAAM,CAAC;QACrD,CAAC;QAED,IAAI,CAAC,GAAG,kBAAkB,GAAG,MAAM,CAAC,WAAW,GAAG,MAAM,EAAE,CAAC;YACzD,CAAC,GAAG,MAAM,CAAC,WAAW,GAAG,kBAAkB,GAAG,MAAM,CAAC;QACvD,CAAC;QAED,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACxB,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAExB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,oBAAoB,GAAG,IAAI,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.commandManager.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() },
@@ -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,SA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;QAChC,YAAY,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC;IAED,aAAa,CAAC,KAAoB;QAChC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC;QAExD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE1K,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,WAAW,CAAC,KAAoB;QAC9B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { KritzelToolRegistry } from '../registries/tool.registry';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } 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"]}
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,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE;QAClG,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE;QAE1F,UAAU;QACV,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;QACvD,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE;QAEvD,iBAAiB;QACjB,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QACpE,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IA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QAExD,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE1K,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9B,CAAC;IACH,CAAC;IAED,WAAW,CAAC,KAAoB;QAC9B,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC;IAC1D,CAAC;CACF","sourcesContent":["import { KritzelToolRegistry } from '../registries/tool.registry';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } 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"]}
@@ -76,10 +76,15 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
76
76
  const clientY = event.clientY - this._core.store.offsetY;
77
77
  this.endX = clientX;
78
78
  this.endY = clientY;
79
- this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
80
- this.dragStartX = clientX;
81
- this.dragStartY = clientY;
82
- this.hasMoved = true;
79
+ const moveDeltaX = Math.abs(clientX - this.startX);
80
+ const moveDeltaY = Math.abs(clientY - this.startY);
81
+ const moveThreshold = 5;
82
+ if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {
83
+ this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
84
+ this.dragStartX = clientX;
85
+ this.dragStartY = clientY;
86
+ this.hasMoved = true;
87
+ }
83
88
  }
84
89
  }
85
90
  if (event.pointerType === 'touch') {
@@ -114,7 +119,7 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
114
119
  if (this._core.store.state.isDragging) {
115
120
  this._core.store.state.isDragging = false;
116
121
  if (this.hasMoved) {
117
- this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
122
+ this._core.commandManager.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
118
123
  this._core.store.state.hasObjectsChanged = true;
119
124
  }
120
125
  }
@@ -123,7 +128,7 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
123
128
  if (this._core.store.state.isDragging) {
124
129
  this._core.store.state.isDragging = false;
125
130
  if (this.hasMoved) {
126
- this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
131
+ this._core.commandManager.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
127
132
  this._core.store.state.hasObjectsChanged = true;
128
133
  }
129
134
  }
@@ -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;AA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AAC;oBAClB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,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,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,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAE1C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,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"]}
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,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,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AC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAE1C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBAClB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,IAAI,yBAAyB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;oBAChJ,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 \r\n const moveDeltaX = Math.abs(clientX - this.startX);\r\n const moveDeltaY = Math.abs(clientY - this.startY);\r\n const moveThreshold = 5;\r\n \r\n if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {\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\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.commandManager.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.commandManager.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"]}
@@ -7,6 +7,7 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
7
7
  initialMouseY = 0;
8
8
  initialSize = { x: 0, y: 0, width: 0, height: 0 };
9
9
  newSize = { x: 0, y: 0, width: 0, height: 0 };
10
+ hasResized = false;
10
11
  constructor(core) {
11
12
  super(core);
12
13
  }
@@ -15,6 +16,7 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
15
16
  this.initialMouseY = 0;
16
17
  this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
17
18
  this.newSize = { x: 0, y: 0, width: 0, height: 0 };
19
+ this.hasResized = false;
18
20
  }
19
21
  handlePointerDown(event) {
20
22
  if (event.pointerType === 'mouse') {
@@ -61,6 +63,15 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
61
63
  const clientY = event.clientY - this._core.store.offsetY;
62
64
  const dx = clientX - this.initialMouseX;
63
65
  const dy = clientY - this.initialMouseY;
66
+ const resizeDeltaX = Math.abs(dx);
67
+ const resizeDeltaY = Math.abs(dy);
68
+ const resizeThreshold = 5;
69
+ if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {
70
+ this.hasResized = true;
71
+ }
72
+ if (!this.hasResized) {
73
+ return;
74
+ }
64
75
  switch (this._core.store.state.resizeHandleType) {
65
76
  case KritzelHandleType.TopLeft:
66
77
  this.newSize.width = this.initialSize.width - dx;
@@ -101,6 +112,16 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
101
112
  const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);
102
113
  const dx = clientX - this.initialMouseX;
103
114
  const dy = clientY - this.initialMouseY;
115
+ const resizeDeltaX = Math.abs(dx);
116
+ const resizeDeltaY = Math.abs(dy);
117
+ const resizeThreshold = 5;
118
+ if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {
119
+ clearTimeout(this._core.store.state.longTouchTimeout);
120
+ this.hasResized = true;
121
+ }
122
+ if (!this.hasResized) {
123
+ return;
124
+ }
104
125
  switch (this._core.store.state.resizeHandleType) {
105
126
  case KritzelHandleType.TopLeft:
106
127
  this.newSize.width = this.initialSize.width - dx;
@@ -128,24 +149,27 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
128
149
  break;
129
150
  }
130
151
  this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
131
- clearTimeout(this._core.store.state.longTouchTimeout);
132
152
  }
133
153
  }
134
154
  }
135
155
  handlePointerUp(event) {
136
156
  if (event.pointerType === 'mouse') {
137
157
  if (this._core.store.state.isResizing) {
138
- this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
139
158
  this._core.store.state.isResizing = false;
140
- this._core.store.state.hasObjectsChanged = true;
159
+ if (this.hasResized) {
160
+ this._core.commandManager.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
161
+ this._core.store.state.hasObjectsChanged = true;
162
+ }
141
163
  this.reset();
142
164
  }
143
165
  }
144
166
  if (event.pointerType === 'touch') {
145
167
  if (this._core.store.state.isResizing) {
146
- this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
147
168
  this._core.store.state.isResizing = false;
148
- this._core.store.state.hasObjectsChanged = true;
169
+ if (this.hasResized) {
170
+ this._core.commandManager.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
171
+ this._core.store.state.hasObjectsChanged = true;
172
+ }
149
173
  this.reset();
150
174
  clearTimeout(this._core.store.state.longTouchTimeout);
151
175
  }