kritzel-stencil 0.0.132 → 0.0.133

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 (85) hide show
  1. package/dist/cjs/{index-ouFX0OVi.js → index-DCHCVnOl.js} +87 -72
  2. package/dist/cjs/index-DCHCVnOl.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-color_22.cjs.entry.js +16 -15
  5. package/dist/collection/classes/commands/move-selection-group.command.js +8 -0
  6. package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
  7. package/dist/collection/classes/commands/resize-selection-group.command.js +8 -0
  8. package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
  9. package/dist/collection/classes/commands/rotate-selection-group.command.js +5 -3
  10. package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
  11. package/dist/collection/classes/commands/update-object.command.js +2 -0
  12. package/dist/collection/classes/commands/update-object.command.js.map +1 -1
  13. package/dist/collection/classes/core/core.class.js +4 -8
  14. package/dist/collection/classes/core/core.class.js.map +1 -1
  15. package/dist/collection/classes/handlers/context-menu.handler.js +7 -2
  16. package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
  17. package/dist/collection/classes/handlers/move.handler.js +24 -19
  18. package/dist/collection/classes/handlers/move.handler.js.map +1 -1
  19. package/dist/collection/classes/handlers/resize.handler.js +10 -12
  20. package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
  21. package/dist/collection/classes/handlers/rotation.handler.js +14 -22
  22. package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
  23. package/dist/collection/classes/objects/base-object.class.js +11 -3
  24. package/dist/collection/classes/objects/base-object.class.js.map +1 -1
  25. package/dist/collection/classes/objects/selection-group.class.js +3 -4
  26. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  27. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +6 -4
  28. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  29. package/dist/collection/helpers/object.helper.js +0 -14
  30. package/dist/collection/helpers/object.helper.js.map +1 -1
  31. package/dist/collection/interfaces/clonable.interface.js +2 -0
  32. package/dist/collection/interfaces/clonable.interface.js.map +1 -0
  33. package/dist/components/index.js +2 -2
  34. package/dist/components/kritzel-controls.js +1 -1
  35. package/dist/components/kritzel-editor.js +7 -7
  36. package/dist/components/kritzel-engine.js +1 -1
  37. package/dist/components/kritzel-menu-item.js +1 -1
  38. package/dist/components/kritzel-menu.js +1 -1
  39. package/dist/components/kritzel-portal.js +1 -1
  40. package/dist/components/kritzel-split-button.js +1 -1
  41. package/dist/components/kritzel-workspace-manager.js +1 -1
  42. package/dist/components/p-B0kd2rUI.js +16 -0
  43. package/dist/components/p-B0kd2rUI.js.map +1 -0
  44. package/dist/components/{p-BiCgeOiJ.js → p-B3LGnqFz.js} +3 -3
  45. package/dist/components/{p-BiCgeOiJ.js.map → p-B3LGnqFz.js.map} +1 -1
  46. package/dist/components/{p-C1-nvBx9.js → p-BKvOO7NT.js} +6 -6
  47. package/dist/components/{p-C1-nvBx9.js.map → p-BKvOO7NT.js.map} +1 -1
  48. package/dist/components/{p-CvmWmUK9.js → p-CM8KdFZI.js} +4 -4
  49. package/dist/components/{p-CvmWmUK9.js.map → p-CM8KdFZI.js.map} +1 -1
  50. package/dist/components/{p-B3VQubt_.js → p-CNTK3JOp.js} +16 -6
  51. package/dist/components/p-CNTK3JOp.js.map +1 -0
  52. package/dist/components/{p-Davd1R_4.js → p-CwH-bwjb.js} +91 -71
  53. package/dist/components/p-CwH-bwjb.js.map +1 -0
  54. package/dist/components/{p-D_907-Wd.js → p-Dw4n-4zp.js} +3 -3
  55. package/dist/components/{p-D_907-Wd.js.map → p-Dw4n-4zp.js.map} +1 -1
  56. package/dist/components/{p-CTvJDYFQ.js → p-NP1Htol7.js} +3 -3
  57. package/dist/components/{p-CTvJDYFQ.js.map → p-NP1Htol7.js.map} +1 -1
  58. package/dist/esm/{index-C_uHp-ur.js → index-DY3KqYWc.js} +87 -72
  59. package/dist/esm/index-DY3KqYWc.js.map +1 -0
  60. package/dist/esm/index.js +1 -1
  61. package/dist/esm/kritzel-color_22.entry.js +16 -15
  62. package/dist/stencil/index.esm.js +1 -1
  63. package/dist/stencil/p-DY3KqYWc.js +2 -0
  64. package/dist/stencil/p-DY3KqYWc.js.map +1 -0
  65. package/dist/stencil/p-dc534b01.entry.js +2 -0
  66. package/dist/stencil/p-dc534b01.entry.js.map +1 -0
  67. package/dist/stencil/stencil.esm.js +1 -1
  68. package/dist/types/classes/commands/rotate-selection-group.command.d.ts +1 -1
  69. package/dist/types/classes/handlers/move.handler.d.ts +2 -0
  70. package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
  71. package/dist/types/classes/handlers/rotation.handler.d.ts +4 -0
  72. package/dist/types/classes/objects/base-object.class.d.ts +3 -1
  73. package/dist/types/helpers/object.helper.d.ts +0 -2
  74. package/dist/types/interfaces/clonable.interface.d.ts +3 -0
  75. package/package.json +64 -64
  76. package/dist/cjs/index-ouFX0OVi.js.map +0 -1
  77. package/dist/components/p-B3VQubt_.js.map +0 -1
  78. package/dist/components/p-Davd1R_4.js.map +0 -1
  79. package/dist/components/p-EXPChOF6.js +0 -30
  80. package/dist/components/p-EXPChOF6.js.map +0 -1
  81. package/dist/esm/index-C_uHp-ur.js.map +0 -1
  82. package/dist/stencil/p-C_uHp-ur.js +0 -2
  83. package/dist/stencil/p-C_uHp-ur.js.map +0 -1
  84. package/dist/stencil/p-a6f8283e.entry.js +0 -2
  85. package/dist/stencil/p-a6f8283e.entry.js.map +0 -1
@@ -1,8 +1,6 @@
1
1
  import { KritzelEventHelper } from "../../helpers/event.helper";
2
2
  import { MoveSelectionGroupCommand } from "../commands/move-selection-group.command";
3
3
  import { KritzelBaseHandler } from "./base.handler";
4
- import { UpdateObjectCommand } from "../commands/update-object.command";
5
- import { BatchCommand } from "../commands/batch.command";
6
4
  export class KritzelMoveHandler extends KritzelBaseHandler {
7
5
  dragStartX;
8
6
  dragStartY;
@@ -10,9 +8,19 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
10
8
  startY;
11
9
  endX;
12
10
  endY;
11
+ hasMoved = false;
13
12
  constructor(core) {
14
13
  super(core);
15
14
  }
15
+ reset() {
16
+ this.dragStartX = 0;
17
+ this.dragStartY = 0;
18
+ this.startX = 0;
19
+ this.startY = 0;
20
+ this.endX = 0;
21
+ this.endY = 0;
22
+ this.hasMoved = false;
23
+ }
16
24
  handlePointerDown(event) {
17
25
  if (event.pointerType === 'mouse') {
18
26
  if (KritzelEventHelper.isLeftClick(event)) {
@@ -51,16 +59,21 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
51
59
  this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
52
60
  this.dragStartX = clientX;
53
61
  this.dragStartY = clientY;
62
+ this.hasMoved = true;
54
63
  }
55
64
  }
56
65
  if (event.pointerType === 'touch') {
57
66
  const activePointers = Array.from(this._core.store.state.pointers.values());
58
- if (this._core.store.state.pointers.size === 1 && this._core.store.state.selectionGroup && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {
67
+ if (this._core.store.state.pointers.size === 1 &&
68
+ this._core.store.state.selectionGroup &&
69
+ !this._core.store.state.isResizeHandleSelected &&
70
+ !this._core.store.state.isRotationHandleSelected) {
59
71
  const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
60
72
  const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
61
73
  this._core.store.setState('isDragging', true);
62
74
  this.endX = x;
63
75
  this.endY = y;
76
+ this.hasMoved = true;
64
77
  const moveDeltaX = Math.abs(x - this.startX);
65
78
  const moveDeltaY = Math.abs(y - this.startY);
66
79
  const moveThreshold = 5;
@@ -77,27 +90,19 @@ export class KritzelMoveHandler extends KritzelBaseHandler {
77
90
  if (event.pointerType === 'mouse') {
78
91
  if (this._core.store.state.isDragging) {
79
92
  this._core.store.setState('isDragging', false);
80
- const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);
81
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
82
- return new UpdateObjectCommand(this._core, this, object, {
83
- translateX: object.translateX,
84
- translateY: object.translateY
85
- });
86
- });
87
- this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
93
+ if (this.hasMoved) {
94
+ this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
95
+ }
96
+ this.reset();
88
97
  }
89
98
  }
90
99
  if (event.pointerType === 'touch') {
91
100
  if (this._core.store.state.isDragging) {
92
101
  this._core.store.setState('isDragging', false);
93
- const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);
94
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
95
- return new UpdateObjectCommand(this._core, this, object, {
96
- translateX: object.translateX,
97
- translateY: object.translateY
98
- });
99
- });
100
- this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
102
+ if (this.hasMoved) {
103
+ this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
104
+ }
105
+ this.reset();
101
106
  }
102
107
  }
103
108
  }
@@ -1 +1 @@
1
- {"version":3,"file":"move.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/move.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,MAAM,OAA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AU;wBAC7B,UAAU,EAAE,MAAM,CAAC,UAAU;qBAC9B,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,yBAAyB,EAAE,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;YAC9H,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { MoveSelectionGroupCommand } from '../commands/move-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { UpdateObjectCommand } from '../commands/update-object.command';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { KritzelCore } from '../core/core.class';\r\n\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 constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isDragging', true);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.startX = this.dragStartX;\r\n this.startY = this.dragStartY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (this._core.store.state.pointers.size === 1) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n this.startX = x;\r\n this.startY = y;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this.endX = clientX;\r\n this.endY = clientY;\r\n this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n }\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 && this._core.store.state.selectionGroup && !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._core.store.setState('isDragging', true);\r\n this.endX = x;\r\n this.endY = y;\r\n\r\n const moveDeltaX = Math.abs(x - this.startX);\r\n const moveDeltaY = Math.abs(y - this.startY);\r\n const moveThreshold = 5;\r\n\r\n if (moveDeltaX > moveThreshold || moveDeltaY > moveThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n\r\n this._core.store.state.selectionGroup.move(x, y, this.dragStartX, this.dragStartY);\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.setState('isDragging', false);\r\n const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);\r\n const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._core, this, object, {\r\n translateX: object.translateX,\r\n translateY: object.translateY\r\n });\r\n });\r\n\r\n this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.setState('isDragging', false);\r\n const moveSelectionGroupCommand = new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true);\r\n const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._core, this, object, {\r\n translateX: object.translateX,\r\n translateY: object.translateY\r\n });\r\n });\r\n\r\n this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"move.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/move.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,yBAAyB,EAAE,MAAM,0CAA0C,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,OAAO,kBAAmB,SAAQ,kBAAkB;IACxD,UAAU,CAAS;IACnB,UAAU,CAAS;IAEnB,MAAM,CAAS;IACf,MAAM,CAAS;IAEf,IAAI,CAAS;IACb,IAAI,CAAS;IAEb,QAAQ,GAAY,KAAK,CAAC;IAE1B,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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EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC3I,CAAC;gBAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAE/C,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;gBAC3I,CAAC;gBAED,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { MoveSelectionGroupCommand } from '../commands/move-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nexport class KritzelMoveHandler extends KritzelBaseHandler {\r\n dragStartX: number;\r\n dragStartY: number;\r\n\r\n startX: number;\r\n startY: number;\r\n\r\n endX: number;\r\n endY: number;\r\n\r\n hasMoved: boolean = false;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.dragStartX = 0;\r\n this.dragStartY = 0;\r\n this.startX = 0;\r\n this.startY = 0;\r\n this.endX = 0;\r\n this.endY = 0;\r\n this.hasMoved = false;\r\n }\r\n\r\n handlePointerDown(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isDragging', true);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.startX = this.dragStartX;\r\n this.startY = this.dragStartY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (this._core.store.state.pointers.size === 1) {\r\n if (this._core.store.state.selectionGroup?.isSelected && !this._core.store.state.isResizeHandleSelected && !this._core.store.state.isRotationHandleSelected) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this.dragStartX = x;\r\n this.dragStartY = y;\r\n this.startX = x;\r\n this.startY = y;\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this.endX = clientX;\r\n this.endY = clientY;\r\n this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);\r\n this.dragStartX = clientX;\r\n this.dragStartY = clientY;\r\n this.hasMoved = true;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n\r\n if (\r\n this._core.store.state.pointers.size === 1 &&\r\n this._core.store.state.selectionGroup &&\r\n !this._core.store.state.isResizeHandleSelected &&\r\n !this._core.store.state.isRotationHandleSelected\r\n ) {\r\n const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);\r\n const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isDragging', true);\r\n this.endX = x;\r\n this.endY = y;\r\n this.hasMoved = true;\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 }\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent) {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.setState('isDragging', false);\r\n\r\n if (this.hasMoved) {\r\n this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isDragging) {\r\n this._core.store.setState('isDragging', false);\r\n\r\n if (this.hasMoved) {\r\n this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -1,8 +1,6 @@
1
1
  import { KritzelHandleType } from "../../enums/handle-type.enum";
2
2
  import { KritzelEventHelper } from "../../helpers/event.helper";
3
- import { BatchCommand } from "../commands/batch.command";
4
3
  import { ResizeSelectionGroupCommand } from "../commands/resize-selection-group.command";
5
- import { UpdateObjectCommand } from "../commands/update-object.command";
6
4
  import { KritzelBaseHandler } from "./base.handler";
7
5
  export class KritzelResizeHandler extends KritzelBaseHandler {
8
6
  initialMouseX = 0;
@@ -12,6 +10,12 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
12
10
  constructor(core) {
13
11
  super(core);
14
12
  }
13
+ reset() {
14
+ this.initialMouseX = 0;
15
+ this.initialMouseY = 0;
16
+ this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
17
+ this.newSize = { x: 0, y: 0, width: 0, height: 0 };
18
+ }
15
19
  handlePointerDown(event) {
16
20
  if (event.pointerType === 'mouse') {
17
21
  if (KritzelEventHelper.isLeftClick(event)) {
@@ -131,22 +135,16 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
131
135
  handlePointerUp(event) {
132
136
  if (event.pointerType === 'mouse') {
133
137
  if (this._core.store.state.isResizing) {
134
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));
135
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
136
- return new UpdateObjectCommand(this._core, this, object, { ...object });
137
- });
138
- this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
138
+ this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
139
139
  this._core.store.setState('isResizing', false);
140
+ this.reset();
140
141
  }
141
142
  }
142
143
  if (event.pointerType === 'touch') {
143
144
  if (this._core.store.state.isResizing) {
144
- const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));
145
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
146
- return new UpdateObjectCommand(this._core, this, object, { ...object });
147
- });
148
- this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
145
+ this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
149
146
  this._core.store.setState('isResizing', false);
147
+ this.reset();
150
148
  clearTimeout(this._core.store.state.longTouchTimeout);
151
149
  }
152
150
  }
@@ -1 +1 @@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,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { ResizeSelectionGroupCommand } from '../commands/resize-selection-group.command';\r\nimport { UpdateObjectCommand } from '../commands/update-object.command';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isResizing', true);\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isResizing', true);\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._core, this, object, { ...object });\r\n });\r\n\r\n this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));\r\n\r\n this._core.store.setState('isResizing', false);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._core, this, object, { ...object });\r\n });\r\n\r\n this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));\r\n this._core.store.setState('isResizing', false);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\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;IAC1D,aAAa,GAAW,CAAC,CAAC;IAC1B,aAAa,GAAW,CAAC,CAAC;IAE1B,WAAW,GAA4D,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,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I,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;gBAEvJ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { ResizeSelectionGroupCommand } from '../commands/resize-selection-group.command';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialMouseX = 0;\r\n this.initialMouseY = 0;\r\n this.initialSize = { x: 0, y: 0, width: 0, height: 0 };\r\n this.newSize = { x: 0, y: 0, width: 0, height: 0 };\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isResizing', true);\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isResizing', true);\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._core.store.state.selectionGroup.width;\r\n this.initialSize.height = this._core.store.state.selectionGroup.height;\r\n this.initialSize.x = this._core.store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._core.store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));\r\n\r\n this._core.store.setState('isResizing', false);\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));\r\n\r\n this._core.store.setState('isResizing', false);\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -1,14 +1,19 @@
1
1
  import { KritzelEventHelper } from "../../helpers/event.helper";
2
2
  import { RotateSelectionGroupCommand } from "../commands/rotate-selection-group.command";
3
3
  import { KritzelBaseHandler } from "./base.handler";
4
- import { UpdateObjectCommand } from "../commands/update-object.command";
5
- import { BatchCommand } from "../commands/batch.command";
6
4
  export class KritzelRotationHandler extends KritzelBaseHandler {
7
5
  initialRotation = 0;
8
6
  rotation = 0;
7
+ unchangedObjects = [];
8
+ initialSelectionGroupRotation = 0;
9
9
  constructor(core) {
10
10
  super(core);
11
11
  }
12
+ reset() {
13
+ this.initialRotation = 0;
14
+ this.rotation = 0;
15
+ this.unchangedObjects = [];
16
+ }
12
17
  handlePointerDown(event) {
13
18
  if (event.pointerType === 'mouse') {
14
19
  if (KritzelEventHelper.isLeftClick(event)) {
@@ -20,7 +25,9 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
20
25
  const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
21
26
  const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
22
27
  const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
28
+ this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;
23
29
  this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
30
+ this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
24
31
  }
25
32
  }
26
33
  }
@@ -40,6 +47,7 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
40
47
  const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
41
48
  const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
42
49
  this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
50
+ this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
43
51
  clearTimeout(this._core.store.state.longTouchTimeout);
44
52
  }
45
53
  }
@@ -82,32 +90,16 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
82
90
  handlePointerUp(event) {
83
91
  if (event.pointerType === 'mouse') {
84
92
  if (this._core.store.state.isRotating) {
85
- const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);
86
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
87
- return new UpdateObjectCommand(this._core, this, object, {
88
- rotation: object.rotation,
89
- translateX: object.translateX,
90
- translateY: object.translateY,
91
- });
92
- });
93
- this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
93
+ this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
94
94
  this._core.store.setState('isRotating', false);
95
- this.initialRotation = 0;
96
- this.rotation = 0;
95
+ this.reset();
97
96
  }
98
97
  }
99
98
  if (event.pointerType === 'touch') {
100
99
  if (this._core.store.state.isRotating) {
101
- const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);
102
- const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
103
- return new UpdateObjectCommand(this._core, this, object, {
104
- rotation: object.rotation,
105
- });
106
- });
107
- this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
100
+ this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
108
101
  this._core.store.setState('isRotating', false);
109
- this.initialRotation = 0;
110
- this.rotation = 0;
102
+ this.reset();
111
103
  clearTimeout(this._core.store.state.longTouchTimeout);
112
104
  }
113
105
  }
@@ -1 +1 @@
1
- {"version":3,"file":"rotation.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/rotation.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,eAAe,GAAW,CAAC,CAAC;IAE5B,QAAQ,GAAW,CAAC,CAAC;IAErB,YAAY,IAAiB;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAED,iBAAiB,CAAC,KAAmB;QACnC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,C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CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,2BAA2B,EAAE,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;gBAE9H,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAE/C,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;gBACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;gBAElB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { RotateSelectionGroupCommand } from '../commands/rotate-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { UpdateObjectCommand } from '../commands/update-object.command';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { KritzelCore } from '../core/core.class';\r\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isRotating', true);\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.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._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isRotating', true);\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating) {\r\n const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);\r\n const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._core, this, object, {\r\n rotation: object.rotation,\r\n translateX: object.translateX,\r\n translateY: object.translateY,\r\n });\r\n });\r\n\r\n this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));\r\n\r\n this._core.store.setState('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._core.store.state.isRotating) {\r\n const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._core, this, this.rotation);\r\n const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._core, this, object, {\r\n rotation: object.rotation,\r\n });\r\n });\r\n\r\n this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));\r\n\r\n this._core.store.setState('isRotating', false);\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"rotation.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/rotation.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIpD,MAAM,OAAO,sBAAuB,SAAQ,kBAAkB;IAC5D,eAAe,GAAW,CAAC,CAAC;IAE5B,QAAQ,GAAW,CAAC,CAAC;IAErB,gBAAgB,GAA6B,EAAE,CAAC;IAEhD,6BAA6B,GAAW,CAAC,CAAC;IAE1C,YAAY,IAAiB;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC;IAC7B,CAAC;IAED,iBAAiB,CAAC,KAAmB;QACnC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,kBAAkB,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1C,IAAI,IAAI,CAAC,K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ED,eAAe,CAAC,KAAmB;QACjC,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,6BAA6B,CAAC,CAAC,CAAC;gBAExI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAE/C,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { RotateSelectionGroupCommand } from '../commands/rotate-selection-group.command';\r\nimport { KritzelBaseHandler } from './base.handler';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelBaseObject } from '../objects/base-object.class';\r\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n unchangedObjects: KritzelBaseObject<any>[] = [];\r\n\r\n initialSelectionGroupRotation: number = 0;\r\n\r\n constructor(core: KritzelCore) {\r\n super(core);\r\n }\r\n\r\n private reset() {\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n this.unchangedObjects = [];\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.setState('isRotating', true);\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.setState('isRotating', true);\r\n\r\n const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;\r\n\r\n this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._core.store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;\r\n\r\n const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;\r\n const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._core.store.state.selectionGroup.rotate(this.rotation);\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));\r\n\r\n this._core.store.setState('isRotating', false);\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));\r\n\r\n this._core.store.setState('isRotating', false);\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
@@ -182,6 +182,11 @@ export class KritzelBaseObject {
182
182
  rotate(value) {
183
183
  this.rotation = value;
184
184
  }
185
+ clone() {
186
+ const clone = new KritzelBaseObject();
187
+ Object.assign(clone, this);
188
+ return clone;
189
+ }
185
190
  copy() {
186
191
  const copiedObject = Object.create(Object.getPrototypeOf(this));
187
192
  Object.assign(copiedObject, this);
@@ -193,9 +198,12 @@ export class KritzelBaseObject {
193
198
  // This method can be overridden by subclasses to handle click events when the object is selected.
194
199
  }
195
200
  serialize() {
196
- return {
197
- ...ObjectHelper.clone(this)
198
- };
201
+ const { _core, _elementRef, element, totalWidth, totalHeight, ...remainingProps } = this;
202
+ const clonedProps = structuredClone(remainingProps);
203
+ if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
204
+ clonedProps.element = element.cloneNode(true);
205
+ }
206
+ return clonedProps;
199
207
  }
200
208
  deserialize(object) {
201
209
  Object.assign(this, object);
@@ -1 +1 @@
1
- {"version":3,"file":"base-object.class.js","sourceRoot":"","sources":["../../../src/classes/objects/base-object.class.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAGtE,MAAM,OAAO,iBAAiB;IAC5B,SAAS,GAAW,mBAAmB,CAAC;IAExC,KAAK,CAAc;IACnB,WAAW,CAAI;IAEf,EAAE,CAAS;IACX,WAAW,CAAS;IACpB,CAAC,CAAS;IACV,CAAC,CAAS;IACV,UAAU,CAAS;IACnB,UAAU,CAAS;IACnB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,eAAe,CAAS;IACxB,WAAW,CAAS;IACpB,WAAW,GAAW,CAAC,CAAC;IACxB,OAAO,GAAW,CAAC,CAAC;IACpB,OAAO,GAAW,CAAC,CAAC;IACpB,KAAK,CAAS;IACd,QAAQ,GAAY,KAAK,CAAC;IAC1B,QAAQ,GAAW,CAAC,CAAC;IACrB,gBAAgB,GAAY,KAAK,CAAC;IAClC,MAAM,GAAW,CAAC,CAAC;IAEnB,SAAS,GAAY,IAAI,CAAC;IAC1B,UAAU,GAAY,KAAK,CAAC;IAC5B,SAAS,GAAY,KAAK,CAAC;IAC3B,SAAS,GAAY,KAAK,CAAC;IAC3B,UAAU,GAAY,KAAK,CAAC;IAC5B,aAAa,GAAY,KAAK,CAAC;IAC/B,kBAAkB,GAAY,KAAK,CAAC;IAEpC,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,OAA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Aa,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,OAAO,qBAAqB,CAAC,mBAAmB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED,cAAc,CAAC,CAAS,EAAE,CAAS;QACjC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CAEF","sourcesContent":["import { KritzelBoundingBox } from '../../interfaces/bounding-box.interface';\r\nimport { KritzelObject } from '../../interfaces/object.interface';\r\nimport { KritzelPolygon } from '../../interfaces/polygon.interface';\r\nimport { KritzelSerializable } from '../../interfaces/serializable.interface';\r\nimport { ObjectHelper } from '../../helpers/object.helper';\r\nimport { KritzelGeometryHelper } from '../../helpers/geometry.helper';\r\nimport { KritzelCore } from '../core/core.class';\r\n\r\nexport class KritzelBaseObject<T extends Element = HTMLElement | SVGElement> implements KritzelObject<T>, KritzelSerializable {\r\n __class__: string = 'KritzelBaseObject';\r\n\r\n _core: KritzelCore;\r\n _elementRef: T;\r\n\r\n id: string;\r\n workspaceId: string;\r\n x: number;\r\n y: number;\r\n translateX: number;\r\n translateY: number;\r\n height: number;\r\n width: number;\r\n backgroundColor: string;\r\n borderColor: string;\r\n borderWidth: number = 0;\r\n opacity: number = 1;\r\n padding: number = 0;\r\n scale: number;\r\n resizing: boolean = false;\r\n rotation: number = 0;\r\n markedForRemoval: boolean = false;\r\n zIndex: number = 0;\r\n\r\n isVisible: boolean = true;\r\n isSelected: boolean = false;\r\n isHovered: boolean = false;\r\n isMounted: boolean = false;\r\n isEditable: boolean = false;\r\n isInteractive: boolean = false;\r\n isDebugInfoVisible: boolean = false;\r\n\r\n get totalWidth(): number {\r\n return this.width + this.padding * 2;\r\n }\r\n\r\n get totalHeight(): number {\r\n return this.height + this.padding * 2;\r\n }\r\n\r\n set elementRef(element: T) {\r\n this._elementRef = element;\r\n }\r\n\r\n get elementRef(): T {\r\n return this._elementRef;\r\n }\r\n\r\n get boundingBox(): KritzelBoundingBox {\r\n return {\r\n x: this.translateX,\r\n y: this.translateY,\r\n z: this.scale,\r\n width: this.totalWidth / this.scale,\r\n height: this.totalHeight / this.scale,\r\n depth: 0,\r\n };\r\n }\r\n\r\n get rotatedBoundingBox(): KritzelBoundingBox {\r\n return {\r\n x: this.minXRotated,\r\n y: this.minYRotated,\r\n z: this.scale,\r\n width: this.maxXRotated - this.minXRotated,\r\n height: this.maxYRotated - this.minYRotated,\r\n depth: 0,\r\n };\r\n }\r\n\r\n get rotatedPolygon(): KritzelPolygon {\r\n const cx = this.translateX + this.totalWidth / 2 / this.scale;\r\n const cy = this.translateY + this.totalHeight / 2 / this.scale;\r\n const angle = this.rotation;\r\n\r\n const adjustedWidth = this.totalWidth / this.scale;\r\n const adjustedHeight = this.totalHeight / this.scale;\r\n\r\n const corners = {\r\n topLeft: { x: this.translateX, y: this.translateY },\r\n topRight: { x: this.translateX + adjustedWidth, y: this.translateY },\r\n bottomRight: { x: this.translateX + adjustedWidth, y: this.translateY + adjustedHeight },\r\n bottomLeft: { x: this.translateX, y: this.translateY + adjustedHeight },\r\n };\r\n\r\n const rotatedCorners = Object.keys(corners).reduce((acc, key) => {\r\n const corner = corners[key];\r\n const rotatedX = Math.cos(angle) * (corner.x - cx) - Math.sin(angle) * (corner.y - cy) + cx;\r\n const rotatedY = Math.sin(angle) * (corner.x - cx) + Math.cos(angle) * (corner.y - cy) + cy;\r\n acc[key] = { x: rotatedX, y: rotatedY };\r\n return acc;\r\n }, {});\r\n\r\n return rotatedCorners as KritzelPolygon;\r\n }\r\n\r\n get minXRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];\r\n\r\n return Math.min(...corners);\r\n }\r\n\r\n get minYRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];\r\n\r\n return Math.min(...corners);\r\n }\r\n\r\n get maxXRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];\r\n\r\n return Math.max(...corners);\r\n }\r\n\r\n get maxYRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];\r\n\r\n return Math.max(...corners);\r\n }\r\n\r\n get transformationMatrix(): string {\r\n const scale = 1 / this.scale;\r\n const translateX = this.translateX;\r\n const translateY = this.translateY;\r\n\r\n return `matrix(${scale}, 0, 0, ${scale}, ${translateX}, ${translateY})`;\r\n }\r\n\r\n get rotationDegrees(): number {\r\n return this.rotation * (180 / Math.PI);\r\n }\r\n\r\n get centerX(): number {\r\n return this.translateX + this.totalWidth / 2;\r\n }\r\n\r\n get centerY(): number {\r\n return this.translateY + this.totalHeight / 2;\r\n }\r\n\r\n constructor() {\r\n this.id = this.generateId();\r\n }\r\n\r\n static create(core: KritzelCore): KritzelBaseObject<Element> {\r\n const object = new KritzelBaseObject();\r\n\r\n object._core = core;\r\n object.zIndex = core.store.currentZIndex;\r\n object.workspaceId = core.store.state.activeWorkspace.id;\r\n\r\n return object;\r\n }\r\n\r\n mount(element: T): void {\r\n if (this.isMounted) {\r\n return;\r\n }\r\n\r\n this.elementRef = element;\r\n this.isMounted = true;\r\n }\r\n\r\n unmount(): void {\r\n if (!this.isMounted) {\r\n return;\r\n }\r\n\r\n this.isMounted = false;\r\n }\r\n\r\n remount(): void {\r\n if (!this.isMounted) {\r\n return;\r\n }\r\n\r\n this.isMounted = false;\r\n }\r\n\r\n generateId(): string {\r\n return ObjectHelper.generateUUID();\r\n }\r\n\r\n isInViewport(): boolean {\r\n const viewportBounds: KritzelBoundingBox = {\r\n x: -this._core.store.state.translateX / this._core.store.state.scale,\r\n y: -this._core.store.state.translateY / this._core.store.state.scale,\r\n z: this._core.store.state.scale,\r\n width: this._core.store.state.viewportWidth / this._core.store.state.scale,\r\n height: this._core.store.state.viewportHeight / this._core.store.state.scale,\r\n depth: 100,\r\n };\r\n\r\n return (\r\n this.boundingBox.x < viewportBounds.x + viewportBounds.width &&\r\n this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&\r\n this.boundingBox.y < viewportBounds.y + viewportBounds.height &&\r\n this.boundingBox.y + this.boundingBox.height > viewportBounds.y\r\n );\r\n }\r\n\r\n centerInViewport(): void {\r\n const scale = this._core.store.state.scale;\r\n this.translateX = (this._core.store.state.viewportWidth / 2 - this.totalWidth / 2 - this._core.store.state.translateX) / scale;\r\n this.translateY = (this._core.store.state.viewportHeight / 2 - this.totalHeight / 2 - this._core.store.state.translateY) / scale;\r\n }\r\n\r\n move(startX: number, startY: number, endX: number, endY: number): void {\r\n const deltaX = (startX - endX) / this._core.store.state.scale;\r\n const deltaY = (startY - endY) / this._core.store.state.scale;\r\n\r\n this.translateX += deltaX;\r\n this.translateY += deltaY;\r\n }\r\n\r\n resize(x: number, y: number, width: number, height: number): void {\r\n if (width <= 1 || height <= 1) {\r\n return;\r\n }\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.translateX = x;\r\n this.translateY = y;\r\n }\r\n\r\n rotate(value: number): void {\r\n this.rotation = value;\r\n }\r\n\r\n copy(): KritzelBaseObject<T> {\r\n const copiedObject: KritzelBaseObject<T> = Object.create(Object.getPrototypeOf(this));\r\n Object.assign(copiedObject, this);\r\n copiedObject.id = this.generateId();\r\n copiedObject.isMounted = false;\r\n return copiedObject;\r\n }\r\n\r\n onSelectedClick(): void {\r\n // This method can be overridden by subclasses to handle click events when the object is selected.\r\n }\r\n\r\n serialize() {\r\n return {\r\n ...ObjectHelper.clone(this)\r\n };\r\n }\r\n\r\n deserialize(object: any): KritzelBaseObject<T> {\r\n Object.assign(this, object);\r\n return this;\r\n }\r\n\r\n isClass<T extends KritzelBaseObject>(this: T, className: string): this is T {\r\n return this.__class__ === className;\r\n }\r\n\r\n edit(): void {\r\n // This method can be overridden by subclasses to handle edit actions.\r\n }\r\n\r\n hitTest(_x: number, _y: number): boolean {\r\n return true; // Default implementation, can be overridden by subclasses\r\n }\r\n\r\n hitTestPolygon(polygon: KritzelPolygon): boolean {\r\n const objectPolygon = this.rotatedPolygon;\r\n return KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, polygon);\r\n }\r\n\r\n updatePosition(x: number, y: number): void {\r\n this.translateX = x;\r\n this.translateY = y;\r\n this._core.store.state.objectsMap.update(this);\r\n }\r\n\r\n}\r\n"]}
1
+ {"version":3,"file":"base-object.class.js","sourceRoot":"","sources":["../../../src/classes/objects/base-object.class.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAItE,MAAM,OAAO,iBAAiB;IAC5B,SAAS,GAAW,mBAAmB,CAAC;IAExC,KAAK,CAAc;IACnB,WAAW,CAAI;IAEf,EAAE,CAAS;IACX,WAAW,CAAS;IACpB,CAAC,CAAS;IACV,CAAC,CAAS;IACV,UAAU,CAAS;IACnB,UAAU,CAAS;IACnB,MAAM,CAAS;IACf,KAAK,CAAS;IACd,eAAe,CAAS;IACxB,WAAW,CAAS;IACpB,WAAW,GAAW,CAAC,CAAC;IACxB,OAAO,GAAW,CAAC,CAAC;IACpB,OAAO,GAAW,CAAC,CAAC;IACpB,KAAK,CAAS;IACd,QAAQ,GAAY,KAAK,CAAC;IAC1B,QAAQ,GAAW,CAAC,CAAC;IACrB,gBAAgB,GAAY,KAAK,CAAC;IAClC,MAAM,GAAW,CAAC,CAAC;IAEnB,SAAS,GAAY,IAAI,CAAC;IAC1B,UAAU,GAAY,KAAK,CAA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AE,WAAW,EAAE,GAAG,cAAc,EAAE,GAAG,IAAW,CAAC;QAEhG,MAAM,WAAW,GAAG,eAAe,CAAC,cAAc,CAAC,CAAC;QAEpD,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,UAAU,IAAI,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,CAAC,EAAE,CAAC;YAC9F,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,IAAI,CAAgB,CAAC;QAC/D,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,WAAW,CAAC,MAAW;QACrB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAuC,SAAiB;QAC7D,OAAO,IAAI,CAAC,SAAS,KAAK,SAAS,CAAC;IACtC,CAAC;IAED,IAAI;QACF,sEAAsE;IACxE,CAAC;IAED,OAAO,CAAC,EAAU,EAAE,EAAU;QAC5B,OAAO,IAAI,CAAC,CAAC,0DAA0D;IACzE,CAAC;IAED,cAAc,CAAC,OAAuB;QACpC,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC;QAC1C,OAAO,qBAAqB,CAAC,mBAAmB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;IAED,cAAc,CAAC,CAAS,EAAE,CAAS;QACjC,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjD,CAAC;CAEF","sourcesContent":["import { KritzelBoundingBox } from '../../interfaces/bounding-box.interface';\r\nimport { KritzelObject } from '../../interfaces/object.interface';\r\nimport { KritzelPolygon } from '../../interfaces/polygon.interface';\r\nimport { KritzelSerializable } from '../../interfaces/serializable.interface';\r\nimport { ObjectHelper } from '../../helpers/object.helper';\r\nimport { KritzelGeometryHelper } from '../../helpers/geometry.helper';\r\nimport { KritzelCore } from '../core/core.class';\r\nimport { KritzelClonable } from '../../interfaces/clonable.interface';\r\n\r\nexport class KritzelBaseObject<T extends Element = HTMLElement | SVGElement> implements KritzelObject<T>, KritzelSerializable, KritzelClonable<KritzelBaseObject<T>> {\r\n __class__: string = 'KritzelBaseObject';\r\n\r\n _core: KritzelCore;\r\n _elementRef: T;\r\n\r\n id: string;\r\n workspaceId: string;\r\n x: number;\r\n y: number;\r\n translateX: number;\r\n translateY: number;\r\n height: number;\r\n width: number;\r\n backgroundColor: string;\r\n borderColor: string;\r\n borderWidth: number = 0;\r\n opacity: number = 1;\r\n padding: number = 0;\r\n scale: number;\r\n resizing: boolean = false;\r\n rotation: number = 0;\r\n markedForRemoval: boolean = false;\r\n zIndex: number = 0;\r\n\r\n isVisible: boolean = true;\r\n isSelected: boolean = false;\r\n isHovered: boolean = false;\r\n isMounted: boolean = false;\r\n isEditable: boolean = false;\r\n isInteractive: boolean = false;\r\n isDebugInfoVisible: boolean = false;\r\n\r\n get totalWidth(): number {\r\n return this.width + this.padding * 2;\r\n }\r\n\r\n get totalHeight(): number {\r\n return this.height + this.padding * 2;\r\n }\r\n\r\n set elementRef(element: T) {\r\n this._elementRef = element;\r\n }\r\n\r\n get elementRef(): T {\r\n return this._elementRef;\r\n }\r\n\r\n get boundingBox(): KritzelBoundingBox {\r\n return {\r\n x: this.translateX,\r\n y: this.translateY,\r\n z: this.scale,\r\n width: this.totalWidth / this.scale,\r\n height: this.totalHeight / this.scale,\r\n depth: 0,\r\n };\r\n }\r\n\r\n get rotatedBoundingBox(): KritzelBoundingBox {\r\n return {\r\n x: this.minXRotated,\r\n y: this.minYRotated,\r\n z: this.scale,\r\n width: this.maxXRotated - this.minXRotated,\r\n height: this.maxYRotated - this.minYRotated,\r\n depth: 0,\r\n };\r\n }\r\n\r\n get rotatedPolygon(): KritzelPolygon {\r\n const cx = this.translateX + this.totalWidth / 2 / this.scale;\r\n const cy = this.translateY + this.totalHeight / 2 / this.scale;\r\n const angle = this.rotation;\r\n\r\n const adjustedWidth = this.totalWidth / this.scale;\r\n const adjustedHeight = this.totalHeight / this.scale;\r\n\r\n const corners = {\r\n topLeft: { x: this.translateX, y: this.translateY },\r\n topRight: { x: this.translateX + adjustedWidth, y: this.translateY },\r\n bottomRight: { x: this.translateX + adjustedWidth, y: this.translateY + adjustedHeight },\r\n bottomLeft: { x: this.translateX, y: this.translateY + adjustedHeight },\r\n };\r\n\r\n const rotatedCorners = Object.keys(corners).reduce((acc, key) => {\r\n const corner = corners[key];\r\n const rotatedX = Math.cos(angle) * (corner.x - cx) - Math.sin(angle) * (corner.y - cy) + cx;\r\n const rotatedY = Math.sin(angle) * (corner.x - cx) + Math.cos(angle) * (corner.y - cy) + cy;\r\n acc[key] = { x: rotatedX, y: rotatedY };\r\n return acc;\r\n }, {});\r\n\r\n return rotatedCorners as KritzelPolygon;\r\n }\r\n\r\n get minXRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];\r\n\r\n return Math.min(...corners);\r\n }\r\n\r\n get minYRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];\r\n\r\n return Math.min(...corners);\r\n }\r\n\r\n get maxXRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.x, this.rotatedPolygon.topRight.x, this.rotatedPolygon.bottomRight.x, this.rotatedPolygon.bottomLeft.x];\r\n\r\n return Math.max(...corners);\r\n }\r\n\r\n get maxYRotated(): number {\r\n const corners = [this.rotatedPolygon.topLeft.y, this.rotatedPolygon.topRight.y, this.rotatedPolygon.bottomRight.y, this.rotatedPolygon.bottomLeft.y];\r\n\r\n return Math.max(...corners);\r\n }\r\n\r\n get transformationMatrix(): string {\r\n const scale = 1 / this.scale;\r\n const translateX = this.translateX;\r\n const translateY = this.translateY;\r\n\r\n return `matrix(${scale}, 0, 0, ${scale}, ${translateX}, ${translateY})`;\r\n }\r\n\r\n get rotationDegrees(): number {\r\n return this.rotation * (180 / Math.PI);\r\n }\r\n\r\n get centerX(): number {\r\n return this.translateX + this.totalWidth / 2;\r\n }\r\n\r\n get centerY(): number {\r\n return this.translateY + this.totalHeight / 2;\r\n }\r\n\r\n constructor() {\r\n this.id = this.generateId();\r\n }\r\n\r\n static create(core: KritzelCore): KritzelBaseObject<Element> {\r\n const object = new KritzelBaseObject();\r\n\r\n object._core = core;\r\n object.zIndex = core.store.currentZIndex;\r\n object.workspaceId = core.store.state.activeWorkspace.id;\r\n\r\n return object;\r\n }\r\n\r\n mount(element: T): void {\r\n if (this.isMounted) {\r\n return;\r\n }\r\n\r\n this.elementRef = element;\r\n this.isMounted = true;\r\n }\r\n\r\n unmount(): void {\r\n if (!this.isMounted) {\r\n return;\r\n }\r\n\r\n this.isMounted = false;\r\n }\r\n\r\n remount(): void {\r\n if (!this.isMounted) {\r\n return;\r\n }\r\n\r\n this.isMounted = false;\r\n }\r\n\r\n generateId(): string {\r\n return ObjectHelper.generateUUID();\r\n }\r\n\r\n isInViewport(): boolean {\r\n const viewportBounds: KritzelBoundingBox = {\r\n x: -this._core.store.state.translateX / this._core.store.state.scale,\r\n y: -this._core.store.state.translateY / this._core.store.state.scale,\r\n z: this._core.store.state.scale,\r\n width: this._core.store.state.viewportWidth / this._core.store.state.scale,\r\n height: this._core.store.state.viewportHeight / this._core.store.state.scale,\r\n depth: 100,\r\n };\r\n\r\n return (\r\n this.boundingBox.x < viewportBounds.x + viewportBounds.width &&\r\n this.boundingBox.x + this.boundingBox.width > viewportBounds.x &&\r\n this.boundingBox.y < viewportBounds.y + viewportBounds.height &&\r\n this.boundingBox.y + this.boundingBox.height > viewportBounds.y\r\n );\r\n }\r\n\r\n centerInViewport(): void {\r\n const scale = this._core.store.state.scale;\r\n this.translateX = (this._core.store.state.viewportWidth / 2 - this.totalWidth / 2 - this._core.store.state.translateX) / scale;\r\n this.translateY = (this._core.store.state.viewportHeight / 2 - this.totalHeight / 2 - this._core.store.state.translateY) / scale;\r\n }\r\n\r\n move(startX: number, startY: number, endX: number, endY: number): void {\r\n const deltaX = (startX - endX) / this._core.store.state.scale;\r\n const deltaY = (startY - endY) / this._core.store.state.scale;\r\n\r\n this.translateX += deltaX;\r\n this.translateY += deltaY;\r\n }\r\n\r\n resize(x: number, y: number, width: number, height: number): void {\r\n if (width <= 1 || height <= 1) {\r\n return;\r\n }\r\n\r\n this.width = width;\r\n this.height = height;\r\n this.translateX = x;\r\n this.translateY = y;\r\n }\r\n\r\n rotate(value: number): void {\r\n this.rotation = value;\r\n }\r\n\r\n clone(): KritzelBaseObject<T> {\r\n const clone = new KritzelBaseObject<T>();\r\n Object.assign(clone, this);\r\n return clone;\r\n }\r\n\r\n copy(): KritzelBaseObject<T> {\r\n const copiedObject: KritzelBaseObject<T> = Object.create(Object.getPrototypeOf(this));\r\n Object.assign(copiedObject, this);\r\n copiedObject.id = this.generateId();\r\n copiedObject.isMounted = false;\r\n return copiedObject;\r\n }\r\n\r\n onSelectedClick(): void {\r\n // This method can be overridden by subclasses to handle click events when the object is selected.\r\n }\r\n\r\n serialize() {\r\n const { _core, _elementRef, element, totalWidth, totalHeight, ...remainingProps } = this as any;\r\n\r\n const clonedProps = structuredClone(remainingProps);\r\n\r\n if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {\r\n clonedProps.element = element.cloneNode(true) as HTMLElement;\r\n }\r\n\r\n return clonedProps;\r\n }\r\n\r\n deserialize(object: any): KritzelBaseObject<T> {\r\n Object.assign(this, object);\r\n return this;\r\n }\r\n\r\n isClass<T extends KritzelBaseObject>(this: T, className: string): this is T {\r\n return this.__class__ === className;\r\n }\r\n\r\n edit(): void {\r\n // This method can be overridden by subclasses to handle edit actions.\r\n }\r\n\r\n hitTest(_x: number, _y: number): boolean {\r\n return true; // Default implementation, can be overridden by subclasses\r\n }\r\n\r\n hitTestPolygon(polygon: KritzelPolygon): boolean {\r\n const objectPolygon = this.rotatedPolygon;\r\n return KritzelGeometryHelper.doPolygonsIntersect(objectPolygon, polygon);\r\n }\r\n\r\n updatePosition(x: number, y: number): void {\r\n this.translateX = x;\r\n this.translateY = y;\r\n this._core.store.state.objectsMap.update(this);\r\n }\r\n\r\n}\r\n"]}
@@ -1,4 +1,3 @@
1
- import { ObjectHelper } from "../../helpers/object.helper";
2
1
  import { KritzelReviver } from "../core/reviver.class";
3
2
  import { KritzelBaseObject } from "./base-object.class";
4
3
  export class KritzelSelectionGroup extends KritzelBaseObject {
@@ -29,7 +28,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
29
28
  else {
30
29
  this.objects.splice(index, 1);
31
30
  }
32
- this.unchangedObjects = ObjectHelper.clone(this.objects);
31
+ this.unchangedObjects = this.objects.map(obj => obj.clone());
33
32
  this.refreshObjectDimensions();
34
33
  }
35
34
  deselectAllChildren() {
@@ -80,7 +79,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
80
79
  this._core.store.state.objectsMap.update(child);
81
80
  });
82
81
  this.refreshObjectDimensions();
83
- this.unchangedObjects = ObjectHelper.clone(this.objects);
82
+ this.unchangedObjects = this.objects.map(obj => obj.clone());
84
83
  }
85
84
  rotate(value) {
86
85
  this.rotation = value;
@@ -110,7 +109,7 @@ export class KritzelSelectionGroup extends KritzelBaseObject {
110
109
  selectionGroup.addOrRemove(copiedObject);
111
110
  currentZIndex++;
112
111
  });
113
- selectionGroup.unchangedObjects = ObjectHelper.clone(selectionGroup.objects);
112
+ selectionGroup.unchangedObjects = selectionGroup.objects.map(obj => obj.clone());
114
113
  if (this.objects.length === 1) {
115
114
  selectionGroup.rotation = this.objects[0].rotation;
116
115
  }