kritzel-stencil 0.0.160 → 0.0.162
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{default-text-tool.config-D10FksvZ.js → default-line-tool.config-D1Ns0NmM.js} +3156 -929
- package/dist/cjs/default-line-tool.config-D1Ns0NmM.js.map +1 -0
- package/dist/cjs/index.cjs.js +131 -126
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +1 -1
- package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +538 -198
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/core/core.class.js +140 -3
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/core/reviver.class.js +8 -0
- package/dist/collection/classes/core/reviver.class.js.map +1 -1
- package/dist/collection/classes/core/store.class.js +8 -0
- package/dist/collection/classes/core/store.class.js.map +1 -1
- package/dist/collection/classes/handlers/line-handle.handler.js +383 -0
- package/dist/collection/classes/handlers/line-handle.handler.js.map +1 -0
- package/dist/collection/classes/handlers/move.handler.js +2 -2
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +42 -34
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +12 -8
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/managers/anchor.manager.js +874 -0
- package/dist/collection/classes/managers/anchor.manager.js.map +1 -0
- package/dist/collection/classes/managers/cursor.manager.js +117 -0
- package/dist/collection/classes/managers/cursor.manager.js.map +1 -0
- package/dist/collection/classes/objects/base-object.class.js +4 -2
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/line.class.js +564 -0
- package/dist/collection/classes/objects/line.class.js.map +1 -0
- package/dist/collection/classes/objects/selection-group.class.js +4 -0
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/registries/icon-registry.class.js +7 -1
- package/dist/collection/classes/registries/icon-registry.class.js.map +1 -1
- package/dist/collection/classes/tools/line-tool.class.js +172 -0
- package/dist/collection/classes/tools/line-tool.class.js.map +1 -0
- package/dist/collection/classes/tools/selection-tool.class.js +41 -8
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +11 -2
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.css +0 -14
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +163 -21
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.css +0 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +1 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.css +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.css +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.css +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.css +1 -2
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +2 -2
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.css +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +4 -4
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.css +1 -2
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.css +1 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +4 -4
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +3 -3
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/configs/default-engine-config.js +10 -0
- package/dist/collection/configs/default-engine-config.js.map +1 -1
- package/dist/collection/configs/default-line-tool.config.js +34 -0
- package/dist/collection/configs/default-line-tool.config.js.map +1 -0
- package/dist/collection/helpers/cursor.helper.js +58 -0
- package/dist/collection/helpers/cursor.helper.js.map +1 -0
- package/dist/collection/helpers/geometry.helper.js +42 -0
- package/dist/collection/helpers/geometry.helper.js.map +1 -1
- package/dist/collection/index.js +6 -0
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/anchor.interface.js +2 -0
- package/dist/collection/interfaces/anchor.interface.js.map +1 -0
- package/dist/collection/interfaces/arrow-head.interface.js +2 -0
- package/dist/collection/interfaces/arrow-head.interface.js.map +1 -0
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/line-options.interface.js +2 -0
- package/dist/collection/interfaces/line-options.interface.js.map +1 -0
- package/dist/collection/interfaces/toolbar-control.interface.js.map +1 -1
- package/dist/components/index.js +4 -4
- package/dist/components/kritzel-brush-style.js +3 -3
- package/dist/components/kritzel-brush-style.js.map +1 -1
- package/dist/components/kritzel-color-palette.js +1 -1
- package/dist/components/kritzel-color.js +1 -1
- package/dist/components/kritzel-context-menu.js +1 -1
- package/dist/components/kritzel-control-brush-config.js +1 -1
- package/dist/components/kritzel-control-text-config.js +1 -1
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-cursor-trail.js +1 -1
- package/dist/components/kritzel-dropdown.js +1 -1
- package/dist/components/kritzel-editor.js +64 -23
- package/dist/components/kritzel-editor.js.map +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/kritzel-font-family.js +1 -1
- package/dist/components/kritzel-font-size.js +1 -1
- package/dist/components/kritzel-font.js +1 -1
- package/dist/components/kritzel-icon.js +1 -1
- package/dist/components/kritzel-menu-item.js +1 -1
- package/dist/components/kritzel-menu.js +1 -1
- package/dist/components/kritzel-portal.js +1 -1
- package/dist/components/kritzel-split-button.js +1 -1
- package/dist/components/kritzel-stroke-size.js +1 -1
- package/dist/components/kritzel-tooltip.js +1 -1
- package/dist/components/kritzel-utility-panel.js +1 -1
- package/dist/components/kritzel-workspace-manager.js +1 -1
- package/dist/components/{p-TdCTkEu0.js → p-7_lwv0zQ.js} +7 -7
- package/dist/components/p-7_lwv0zQ.js.map +1 -0
- package/dist/components/{p-CTP479Lf.js → p-9Fzdviju.js} +6 -6
- package/dist/components/{p-CTP479Lf.js.map → p-9Fzdviju.js.map} +1 -1
- package/dist/components/{p-DDmSxM5f.js → p-B6r22FSC.js} +5 -5
- package/dist/components/p-B6r22FSC.js.map +1 -0
- package/dist/components/{p-CLt3HMl6.js → p-B_3OZeom.js} +3 -3
- package/dist/components/{p-CLt3HMl6.js.map → p-B_3OZeom.js.map} +1 -1
- package/dist/components/{p-CIXPLjCu.js → p-BdwB-S9G.js} +3 -3
- package/dist/components/p-BdwB-S9G.js.map +1 -0
- package/dist/components/p-BixlbUD7.js +104 -0
- package/dist/components/p-BixlbUD7.js.map +1 -0
- package/dist/components/{p-D1uj4A4F.js → p-Brd9SxWS.js} +5 -5
- package/dist/components/p-Brd9SxWS.js.map +1 -0
- package/dist/components/{p-Ddh40W3x.js → p-CDteBYm9.js} +9 -9
- package/dist/components/p-CDteBYm9.js.map +1 -0
- package/dist/components/{p-BgznZoBH.js → p-CFH6XRL5.js} +5 -5
- package/dist/components/p-CFH6XRL5.js.map +1 -0
- package/dist/components/{p-B4kxkVe-.js → p-CRGwaUcp.js} +5 -5
- package/dist/components/p-CRGwaUcp.js.map +1 -0
- package/dist/components/{p-uuRJU2R1.js → p-Ck4lGnmt.js} +3 -3
- package/dist/components/{p-uuRJU2R1.js.map → p-Ck4lGnmt.js.map} +1 -1
- package/dist/components/{p-CK6no3mi.js → p-CkD1PQQX.js} +6 -6
- package/dist/components/{p-CK6no3mi.js.map → p-CkD1PQQX.js.map} +1 -1
- package/dist/components/{p-BQg4YML7.js → p-Cqr0Bah5.js} +12 -12
- package/dist/components/p-Cqr0Bah5.js.map +1 -0
- package/dist/components/{p-DTHqEUDc.js → p-CuhOrcET.js} +2861 -390
- package/dist/components/p-CuhOrcET.js.map +1 -0
- package/dist/components/{p-DAfkuR8U.js → p-CvLFRlQU.js} +5 -5
- package/dist/components/p-CvLFRlQU.js.map +1 -0
- package/dist/components/{p-1lIHoOlH.js → p-DKwJJuFb.js} +19 -19
- package/dist/components/p-DKwJJuFb.js.map +1 -0
- package/dist/components/{p-CsA9M6me.js → p-DZ7kxJUx.js} +8 -8
- package/dist/components/p-DZ7kxJUx.js.map +1 -0
- package/dist/components/{p-D4yvhd1d.js → p-LAsVgL2e.js} +4 -4
- package/dist/components/{p-D4yvhd1d.js.map → p-LAsVgL2e.js.map} +1 -1
- package/dist/components/{p-D5Wq4x4r.js → p-OFrACpZf.js} +3 -3
- package/dist/components/{p-D5Wq4x4r.js.map → p-OFrACpZf.js.map} +1 -1
- package/dist/components/{p-C2sWlNsJ.js → p-dMCB4tJA.js} +5 -5
- package/dist/components/p-dMCB4tJA.js.map +1 -0
- package/dist/components/{p-CBYBurdY.js → p-sokRZ7Vn.js} +49 -5
- package/dist/components/p-sokRZ7Vn.js.map +1 -0
- package/dist/esm/{default-text-tool.config-DzqpOikl.js → default-line-tool.config-C35m-d1Y.js} +3150 -930
- package/dist/esm/default-line-tool.config-C35m-d1Y.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-brush-style.entry.js +1 -1
- package/dist/esm/kritzel-brush-style.entry.js.map +1 -1
- package/dist/esm/kritzel-color_22.entry.js +457 -117
- package/dist/esm/loader.js +1 -1
- package/dist/esm/stencil.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/kritzel-brush-style.entry.esm.js.map +1 -1
- package/dist/stencil/p-385bab97.entry.js +2 -0
- package/dist/stencil/{p-d702c5af.entry.js.map → p-385bab97.entry.js.map} +1 -1
- package/dist/stencil/p-C35m-d1Y.js +2 -0
- package/dist/stencil/p-C35m-d1Y.js.map +1 -0
- package/dist/stencil/p-d142ef46.entry.js +10 -0
- package/dist/stencil/p-d142ef46.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/core/core.class.d.ts +18 -0
- package/dist/types/classes/core/store.class.d.ts +3 -0
- package/dist/types/classes/handlers/line-handle.handler.d.ts +34 -0
- package/dist/types/classes/managers/anchor.manager.d.ts +160 -0
- package/dist/types/classes/managers/cursor.manager.d.ts +43 -0
- package/dist/types/classes/objects/line.class.d.ts +98 -0
- package/dist/types/classes/tools/line-tool.class.d.ts +17 -0
- package/dist/types/classes/tools/selection-tool.class.d.ts +4 -0
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +4 -2
- package/dist/types/components.d.ts +7 -5
- package/dist/types/configs/default-line-tool.config.d.ts +2 -0
- package/dist/types/helpers/cursor.helper.d.ts +22 -0
- package/dist/types/helpers/geometry.helper.d.ts +10 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/interfaces/anchor.interface.d.ts +137 -0
- package/dist/types/interfaces/arrow-head.interface.d.ts +26 -0
- package/dist/types/interfaces/engine-state.interface.d.ts +15 -0
- package/dist/types/interfaces/line-options.interface.d.ts +21 -0
- package/dist/types/interfaces/toolbar-control.interface.d.ts +17 -1
- package/package.json +1 -1
- package/dist/cjs/default-text-tool.config-D10FksvZ.js.map +0 -1
- package/dist/components/p-1lIHoOlH.js.map +0 -1
- package/dist/components/p-B4kxkVe-.js.map +0 -1
- package/dist/components/p-BQg4YML7.js.map +0 -1
- package/dist/components/p-BgznZoBH.js.map +0 -1
- package/dist/components/p-Bhtn9qay.js +0 -98
- package/dist/components/p-Bhtn9qay.js.map +0 -1
- package/dist/components/p-C2sWlNsJ.js.map +0 -1
- package/dist/components/p-CBYBurdY.js.map +0 -1
- package/dist/components/p-CIXPLjCu.js.map +0 -1
- package/dist/components/p-CsA9M6me.js.map +0 -1
- package/dist/components/p-D1uj4A4F.js.map +0 -1
- package/dist/components/p-DAfkuR8U.js.map +0 -1
- package/dist/components/p-DDmSxM5f.js.map +0 -1
- package/dist/components/p-DTHqEUDc.js.map +0 -1
- package/dist/components/p-Ddh40W3x.js.map +0 -1
- package/dist/components/p-TdCTkEu0.js.map +0 -1
- package/dist/esm/default-text-tool.config-DzqpOikl.js.map +0 -1
- package/dist/stencil/p-5475442e.entry.js +0 -10
- package/dist/stencil/p-5475442e.entry.js.map +0 -1
- package/dist/stencil/p-DzqpOikl.js +0 -2
- package/dist/stencil/p-DzqpOikl.js.map +0 -1
- package/dist/stencil/p-d702c5af.entry.js +0 -2
|
@@ -77,39 +77,40 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
77
77
|
const rotation = selectionGroup.rotation;
|
|
78
78
|
const sin = Math.sin(rotation);
|
|
79
79
|
const cos = Math.cos(rotation);
|
|
80
|
-
const
|
|
80
|
+
const objectScale = selectionGroup.scale || 1;
|
|
81
|
+
const currentScale = this._core.store.state.scale;
|
|
81
82
|
// Calculate delta in local unrotated space
|
|
82
83
|
// We rotate the screen delta by -rotation to align with the object's axes
|
|
83
|
-
const localDx = dx * cos + dy * sin;
|
|
84
|
-
const localDy = -dx * sin + dy * cos;
|
|
84
|
+
const localDx = (dx * cos + dy * sin) / currentScale;
|
|
85
|
+
const localDy = (-dx * sin + dy * cos) / currentScale;
|
|
85
86
|
// Calculate the center of the selection group before resize
|
|
86
|
-
const initialCenterX = this.initialSize.x + this.initialSize.width /
|
|
87
|
-
const initialCenterY = this.initialSize.y + this.initialSize.height /
|
|
87
|
+
const initialCenterX = this.initialSize.x + this.initialSize.width / objectScale / 2;
|
|
88
|
+
const initialCenterY = this.initialSize.y + this.initialSize.height / objectScale / 2;
|
|
88
89
|
// The center moves by half of the screen delta (scaled)
|
|
89
90
|
// This is true regardless of rotation because the resize happens symmetrically around the center
|
|
90
91
|
// relative to the fixed point logic
|
|
91
|
-
const newCenterX = initialCenterX + dx /
|
|
92
|
-
const newCenterY = initialCenterY + dy /
|
|
92
|
+
const newCenterX = initialCenterX + dx / currentScale / 2;
|
|
93
|
+
const newCenterY = initialCenterY + dy / currentScale / 2;
|
|
93
94
|
switch (this._core.store.state.resizeHandleType) {
|
|
94
95
|
case KritzelHandleType.TopLeft:
|
|
95
|
-
this.newSize.width = this.initialSize.width - localDx;
|
|
96
|
-
this.newSize.height = this.initialSize.height - localDy;
|
|
96
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
97
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
97
98
|
break;
|
|
98
99
|
case KritzelHandleType.TopRight:
|
|
99
|
-
this.newSize.width = this.initialSize.width + localDx;
|
|
100
|
-
this.newSize.height = this.initialSize.height - localDy;
|
|
100
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
101
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
101
102
|
break;
|
|
102
103
|
case KritzelHandleType.BottomLeft:
|
|
103
|
-
this.newSize.width = this.initialSize.width - localDx;
|
|
104
|
-
this.newSize.height = this.initialSize.height + localDy;
|
|
104
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
105
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
105
106
|
break;
|
|
106
107
|
case KritzelHandleType.BottomRight:
|
|
107
|
-
this.newSize.width = this.initialSize.width + localDx;
|
|
108
|
-
this.newSize.height = this.initialSize.height + localDy;
|
|
108
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
109
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
109
110
|
break;
|
|
110
111
|
}
|
|
111
|
-
this.newSize.x = newCenterX - this.newSize.width /
|
|
112
|
-
this.newSize.y = newCenterY - this.newSize.height /
|
|
112
|
+
this.newSize.x = newCenterX - this.newSize.width / objectScale / 2;
|
|
113
|
+
this.newSize.y = newCenterY - this.newSize.height / objectScale / 2;
|
|
113
114
|
selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
114
115
|
}
|
|
115
116
|
}
|
|
@@ -138,33 +139,40 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
138
139
|
const rotation = selectionGroup.rotation;
|
|
139
140
|
const sin = Math.sin(rotation);
|
|
140
141
|
const cos = Math.cos(rotation);
|
|
141
|
-
const
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
const
|
|
147
|
-
|
|
142
|
+
const objectScale = selectionGroup.scale || 1;
|
|
143
|
+
const currentScale = this._core.store.state.scale;
|
|
144
|
+
// Calculate delta in local unrotated space
|
|
145
|
+
// We rotate the screen delta by -rotation to align with the object's axes
|
|
146
|
+
const localDx = (dx * cos + dy * sin) / currentScale;
|
|
147
|
+
const localDy = (-dx * sin + dy * cos) / currentScale;
|
|
148
|
+
// Calculate the center of the selection group before resize
|
|
149
|
+
const initialCenterX = this.initialSize.x + this.initialSize.width / objectScale / 2;
|
|
150
|
+
const initialCenterY = this.initialSize.y + this.initialSize.height / objectScale / 2;
|
|
151
|
+
// The center moves by half of the screen delta (scaled)
|
|
152
|
+
// This is true regardless of rotation because the resize happens symmetrically around the center
|
|
153
|
+
// relative to the fixed point logic
|
|
154
|
+
const newCenterX = initialCenterX + dx / currentScale / 2;
|
|
155
|
+
const newCenterY = initialCenterY + dy / currentScale / 2;
|
|
148
156
|
switch (this._core.store.state.resizeHandleType) {
|
|
149
157
|
case KritzelHandleType.TopLeft:
|
|
150
|
-
this.newSize.width = this.initialSize.width - localDx;
|
|
151
|
-
this.newSize.height = this.initialSize.height - localDy;
|
|
158
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
159
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
152
160
|
break;
|
|
153
161
|
case KritzelHandleType.TopRight:
|
|
154
|
-
this.newSize.width = this.initialSize.width + localDx;
|
|
155
|
-
this.newSize.height = this.initialSize.height - localDy;
|
|
162
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
163
|
+
this.newSize.height = this.initialSize.height - localDy * objectScale;
|
|
156
164
|
break;
|
|
157
165
|
case KritzelHandleType.BottomLeft:
|
|
158
|
-
this.newSize.width = this.initialSize.width - localDx;
|
|
159
|
-
this.newSize.height = this.initialSize.height + localDy;
|
|
166
|
+
this.newSize.width = this.initialSize.width - localDx * objectScale;
|
|
167
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
160
168
|
break;
|
|
161
169
|
case KritzelHandleType.BottomRight:
|
|
162
|
-
this.newSize.width = this.initialSize.width + localDx;
|
|
163
|
-
this.newSize.height = this.initialSize.height + localDy;
|
|
170
|
+
this.newSize.width = this.initialSize.width + localDx * objectScale;
|
|
171
|
+
this.newSize.height = this.initialSize.height + localDy * objectScale;
|
|
164
172
|
break;
|
|
165
173
|
}
|
|
166
|
-
this.newSize.x = newCenterX - this.newSize.width /
|
|
167
|
-
this.newSize.y = newCenterY - this.newSize.height /
|
|
174
|
+
this.newSize.x = newCenterX - this.newSize.width / objectScale / 2;
|
|
175
|
+
this.newSize.y = newCenterY - this.newSize.height / objectScale / 2;
|
|
168
176
|
selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
169
177
|
}
|
|
170
178
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/resize.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,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,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAE3G,OAAO,GAA4D,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;IAEvG,UAAU,GAAY,KAAK,CAAC;IAE5B,YAAY,IAAiB;QAC3B,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC;IAEO,KAAK;QACX,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,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AC,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;oBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAClD,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,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAE1C,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;oBACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;oBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAClD,CAAC;gBAED,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 { 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 hasResized: boolean = false;\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 this.hasResized = false;\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && 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 const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n const rotation = selectionGroup.rotation;\r\n const sin = Math.sin(rotation);\r\n const cos = Math.cos(rotation);\r\n const activeScale = selectionGroup.scale || this._core.store.state.scale;\r\n\r\n // Calculate delta in local unrotated space\r\n // We rotate the screen delta by -rotation to align with the object's axes\r\n const localDx = dx * cos + dy * sin;\r\n const localDy = -dx * sin + dy * cos;\r\n\r\n // Calculate the center of the selection group before resize\r\n const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;\r\n const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;\r\n\r\n // The center moves by half of the screen delta (scaled)\r\n // This is true regardless of rotation because the resize happens symmetrically around the center\r\n // relative to the fixed point logic\r\n const newCenterX = initialCenterX + dx / activeScale / 2;\r\n const newCenterY = initialCenterY + dy / activeScale / 2;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n }\r\n\r\n this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;\r\n this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;\r\n\r\n 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && 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 const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n const rotation = selectionGroup.rotation;\r\n const sin = Math.sin(rotation);\r\n const cos = Math.cos(rotation);\r\n const activeScale = selectionGroup.scale || this._core.store.state.scale;\r\n\r\n const localDx = dx * cos + dy * sin;\r\n const localDy = -dx * sin + dy * cos;\r\n\r\n const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;\r\n const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;\r\n\r\n const newCenterX = initialCenterX + dx / activeScale / 2;\r\n const newCenterY = initialCenterY + dy / activeScale / 2;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height - localDy;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + localDx;\r\n this.newSize.height = this.initialSize.height + localDy;\r\n break;\r\n }\r\n\r\n this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;\r\n this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;\r\n\r\n selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\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.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"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;AAEhE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,aAAa,GAAW,CAAC,CAAC;IAC1B,a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E,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,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAE1C,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;oBACpB,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;oBACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;oBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAClD,CAAC;gBAED,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 { 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 hasResized: boolean = false;\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 this.hasResized = false;\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = selectionGroup.width;\r\n this.initialSize.height = selectionGroup.height;\r\n this.initialSize.x = selectionGroup.translateX;\r\n this.initialSize.y = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && 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 const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n const rotation = selectionGroup.rotation;\r\n const sin = Math.sin(rotation);\r\n const cos = Math.cos(rotation);\r\n const objectScale = selectionGroup.scale || 1;\r\n const currentScale = this._core.store.state.scale;\r\n\r\n // Calculate delta in local unrotated space\r\n // We rotate the screen delta by -rotation to align with the object's axes\r\n const localDx = (dx * cos + dy * sin) / currentScale;\r\n const localDy = (-dx * sin + dy * cos) / currentScale;\r\n\r\n // Calculate the center of the selection group before resize\r\n const initialCenterX = this.initialSize.x + this.initialSize.width / objectScale / 2;\r\n const initialCenterY = this.initialSize.y + this.initialSize.height / objectScale / 2;\r\n\r\n // The center moves by half of the screen delta (scaled)\r\n // This is true regardless of rotation because the resize happens symmetrically around the center\r\n // relative to the fixed point logic\r\n const newCenterX = initialCenterX + dx / currentScale / 2;\r\n const newCenterY = initialCenterY + dy / currentScale / 2;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - localDx * objectScale;\r\n this.newSize.height = this.initialSize.height - localDy * objectScale;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + localDx * objectScale;\r\n this.newSize.height = this.initialSize.height - localDy * objectScale;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - localDx * objectScale;\r\n this.newSize.height = this.initialSize.height + localDy * objectScale;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + localDx * objectScale;\r\n this.newSize.height = this.initialSize.height + localDy * objectScale;\r\n break;\r\n }\r\n\r\n this.newSize.x = newCenterX - this.newSize.width / objectScale / 2;\r\n this.newSize.y = newCenterY - this.newSize.height / objectScale / 2;\r\n\r\n 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isResizing && 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 const resizeDeltaX = Math.abs(dx);\r\n const resizeDeltaY = Math.abs(dy);\r\n const resizeThreshold = 5;\r\n\r\n if (resizeDeltaX > resizeThreshold || resizeDeltaY > resizeThreshold) {\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n this.hasResized = true;\r\n }\r\n\r\n if (!this.hasResized) {\r\n return;\r\n }\r\n\r\n const rotation = selectionGroup.rotation;\r\n const sin = Math.sin(rotation);\r\n const cos = Math.cos(rotation);\r\n const objectScale = selectionGroup.scale || 1;\r\n const currentScale = this._core.store.state.scale;\r\n\r\n // Calculate delta in local unrotated space\r\n // We rotate the screen delta by -rotation to align with the object's axes\r\n const localDx = (dx * cos + dy * sin) / currentScale;\r\n const localDy = (-dx * sin + dy * cos) / currentScale;\r\n\r\n // Calculate the center of the selection group before resize\r\n const initialCenterX = this.initialSize.x + this.initialSize.width / objectScale / 2;\r\n const initialCenterY = this.initialSize.y + this.initialSize.height / objectScale / 2;\r\n\r\n // The center moves by half of the screen delta (scaled)\r\n // This is true regardless of rotation because the resize happens symmetrically around the center\r\n // relative to the fixed point logic\r\n const newCenterX = initialCenterX + dx / currentScale / 2;\r\n const newCenterY = initialCenterY + dy / currentScale / 2;\r\n\r\n switch (this._core.store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - localDx * objectScale;\r\n this.newSize.height = this.initialSize.height - localDy * objectScale;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + localDx * objectScale;\r\n this.newSize.height = this.initialSize.height - localDy * objectScale;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - localDx * objectScale;\r\n this.newSize.height = this.initialSize.height + localDy * objectScale;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + localDx * objectScale;\r\n this.newSize.height = this.initialSize.height + localDy * objectScale;\r\n break;\r\n }\r\n\r\n this.newSize.x = newCenterX - this.newSize.width / objectScale / 2;\r\n this.newSize.y = newCenterY - this.newSize.height / objectScale / 2;\r\n\r\n selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\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.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isResizing) {\r\n this._core.store.state.isResizing = false;\r\n\r\n if (this.hasResized) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.hasObjectsChanged = true;\r\n }\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"]}
|
|
@@ -21,8 +21,9 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
21
21
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
22
22
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
23
23
|
this._core.store.state.isRotating = true;
|
|
24
|
-
const
|
|
25
|
-
const
|
|
24
|
+
const objectScale = selectionGroup.scale || 1;
|
|
25
|
+
const centerX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;
|
|
26
|
+
const centerY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;
|
|
26
27
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
27
28
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
28
29
|
this.initialSelectionGroupRotation = selectionGroup.rotation;
|
|
@@ -43,8 +44,9 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
43
44
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
44
45
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
45
46
|
this._core.store.state.isRotating = true;
|
|
46
|
-
const
|
|
47
|
-
const
|
|
47
|
+
const objectScale = selectionGroup.scale || 1;
|
|
48
|
+
const centerX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;
|
|
49
|
+
const centerY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;
|
|
48
50
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
49
51
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
50
52
|
this.initialSelectionGroupRotation = selectionGroup.rotation;
|
|
@@ -61,8 +63,9 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
61
63
|
if (this._core.store.state.isRotating && selectionGroup) {
|
|
62
64
|
const clientX = event.clientX - this._core.store.offsetX;
|
|
63
65
|
const clientY = event.clientY - this._core.store.offsetY;
|
|
64
|
-
const
|
|
65
|
-
const
|
|
66
|
+
const objectScale = selectionGroup.scale || 1;
|
|
67
|
+
const groupCenterX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;
|
|
68
|
+
const groupCenterY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;
|
|
66
69
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
67
70
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
68
71
|
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
@@ -80,8 +83,9 @@ export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
80
83
|
if (this._core.store.state.isRotating && selectionGroup) {
|
|
81
84
|
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
82
85
|
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
83
|
-
const
|
|
84
|
-
const
|
|
86
|
+
const objectScale = selectionGroup.scale || 1;
|
|
87
|
+
const groupCenterX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;
|
|
88
|
+
const groupCenterY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;
|
|
85
89
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
86
90
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
87
91
|
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
@@ -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,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,CAA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MAAM,CAAC,iBAAiB,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAEhD,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\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 const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isRotating = true;\r\n\r\n const centerX = selectionGroup.translateX + selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = selectionGroup.translateY + 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 = selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - selectionGroup.rotation;\r\n\r\n this.unchangedObjects = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isRotating = true;\r\n\r\n const centerX = selectionGroup.translateX + selectionGroup.width / 2 / this._core.store.state.scale;\r\n const centerY = selectionGroup.translateY + 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 = selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - selectionGroup.rotation;\r\n\r\n this.unchangedObjects = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isRotating && 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 = selectionGroup.translateX + selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = selectionGroup.translateY + 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 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isRotating && 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 = selectionGroup.translateX + selectionGroup.width / 2 / this._core.store.state.scale;\r\n const groupCenterY = selectionGroup.translateY + 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 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.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.isRotating = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.isRotating = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
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,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,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC;gBACvD,IAAI,cAAc,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,wBAAwB,EAAE,CAAC;oBACtE,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;oBACzD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC;oBAEzD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,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EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAEhD,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,CAAC;QACH,CAAC;QAED,IAAI,KAAK,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC;gBACzC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC;gBACtC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC1C,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,iBAAiB,GAAG,IAAI,CAAC;gBAEhD,IAAI,CAAC,KAAK,EAAE,CAAC;gBAEb,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelEventHelper } from '../../helpers/event.helper';\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 const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._core.store.offsetX;\r\n const clientY = event.clientY - this._core.store.offsetY;\r\n\r\n this._core.store.state.isRotating = true;\r\n\r\n const objectScale = selectionGroup.scale || 1;\r\n const centerX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;\r\n const centerY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;\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 = selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - selectionGroup.rotation;\r\n\r\n this.unchangedObjects = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (selectionGroup && this._core.store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);\r\n\r\n this._core.store.state.isRotating = true;\r\n\r\n const objectScale = selectionGroup.scale || 1;\r\n const centerX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;\r\n const centerY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;\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 = selectionGroup.rotation;\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - selectionGroup.rotation;\r\n\r\n this.unchangedObjects = 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isRotating && 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 objectScale = selectionGroup.scale || 1;\r\n const groupCenterX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;\r\n const groupCenterY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;\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 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 const selectionGroup = this._core.store.selectionGroup;\r\n if (this._core.store.state.isRotating && 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 objectScale = selectionGroup.scale || 1;\r\n const groupCenterX = selectionGroup.translateX + selectionGroup.width / 2 / objectScale;\r\n const groupCenterY = selectionGroup.translateY + selectionGroup.height / 2 / objectScale;\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 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.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.isRotating = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._core.store.state.isRotating) {\r\n this._core.store.selectionGroup.update();\r\n this._core.engine.emitObjectsChange();\r\n this._core.store.state.isRotating = false;\r\n this._core.store.state.hasObjectsChanged = true;\r\n\r\n this.reset();\r\n\r\n clearTimeout(this._core.store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|