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.
- package/dist/cjs/{index-ouFX0OVi.js → index-DCHCVnOl.js} +87 -72
- package/dist/cjs/index-DCHCVnOl.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +16 -15
- package/dist/collection/classes/commands/move-selection-group.command.js +8 -0
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +8 -0
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +5 -3
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-object.command.js +2 -0
- package/dist/collection/classes/commands/update-object.command.js.map +1 -1
- package/dist/collection/classes/core/core.class.js +4 -8
- package/dist/collection/classes/core/core.class.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +7 -2
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +24 -19
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +10 -12
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +14 -22
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +11 -3
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +3 -4
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +6 -4
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/helpers/object.helper.js +0 -14
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/interfaces/clonable.interface.js +2 -0
- package/dist/collection/interfaces/clonable.interface.js.map +1 -0
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-controls.js +1 -1
- package/dist/components/kritzel-editor.js +7 -7
- package/dist/components/kritzel-engine.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-workspace-manager.js +1 -1
- package/dist/components/p-B0kd2rUI.js +16 -0
- package/dist/components/p-B0kd2rUI.js.map +1 -0
- package/dist/components/{p-BiCgeOiJ.js → p-B3LGnqFz.js} +3 -3
- package/dist/components/{p-BiCgeOiJ.js.map → p-B3LGnqFz.js.map} +1 -1
- package/dist/components/{p-C1-nvBx9.js → p-BKvOO7NT.js} +6 -6
- package/dist/components/{p-C1-nvBx9.js.map → p-BKvOO7NT.js.map} +1 -1
- package/dist/components/{p-CvmWmUK9.js → p-CM8KdFZI.js} +4 -4
- package/dist/components/{p-CvmWmUK9.js.map → p-CM8KdFZI.js.map} +1 -1
- package/dist/components/{p-B3VQubt_.js → p-CNTK3JOp.js} +16 -6
- package/dist/components/p-CNTK3JOp.js.map +1 -0
- package/dist/components/{p-Davd1R_4.js → p-CwH-bwjb.js} +91 -71
- package/dist/components/p-CwH-bwjb.js.map +1 -0
- package/dist/components/{p-D_907-Wd.js → p-Dw4n-4zp.js} +3 -3
- package/dist/components/{p-D_907-Wd.js.map → p-Dw4n-4zp.js.map} +1 -1
- package/dist/components/{p-CTvJDYFQ.js → p-NP1Htol7.js} +3 -3
- package/dist/components/{p-CTvJDYFQ.js.map → p-NP1Htol7.js.map} +1 -1
- package/dist/esm/{index-C_uHp-ur.js → index-DY3KqYWc.js} +87 -72
- package/dist/esm/index-DY3KqYWc.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-color_22.entry.js +16 -15
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/p-DY3KqYWc.js +2 -0
- package/dist/stencil/p-DY3KqYWc.js.map +1 -0
- package/dist/stencil/p-dc534b01.entry.js +2 -0
- package/dist/stencil/p-dc534b01.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +1 -1
- package/dist/types/classes/handlers/move.handler.d.ts +2 -0
- package/dist/types/classes/handlers/resize.handler.d.ts +1 -0
- package/dist/types/classes/handlers/rotation.handler.d.ts +4 -0
- package/dist/types/classes/objects/base-object.class.d.ts +3 -1
- package/dist/types/helpers/object.helper.d.ts +0 -2
- package/dist/types/interfaces/clonable.interface.d.ts +3 -0
- package/package.json +64 -64
- package/dist/cjs/index-ouFX0OVi.js.map +0 -1
- package/dist/components/p-B3VQubt_.js.map +0 -1
- package/dist/components/p-Davd1R_4.js.map +0 -1
- package/dist/components/p-EXPChOF6.js +0 -30
- package/dist/components/p-EXPChOF6.js.map +0 -1
- package/dist/esm/index-C_uHp-ur.js.map +0 -1
- package/dist/stencil/p-C_uHp-ur.js +0 -2
- package/dist/stencil/p-C_uHp-ur.js.map +0 -1
- package/dist/stencil/p-a6f8283e.entry.js +0 -2
- package/dist/stencil/p-a6f8283e.entry.js.map +0 -1
|
@@ -38,6 +38,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
38
38
|
this.object[key] = this.updatedProperties[key];
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
+
this._core.store.state.objectsMap.update(this.object);
|
|
41
42
|
this._core.updateObjectInDatabase(this.object);
|
|
42
43
|
}
|
|
43
44
|
undo() {
|
|
@@ -46,6 +47,7 @@ class UpdateObjectCommand extends KritzelBaseCommand {
|
|
|
46
47
|
this.object[key] = this.previousProperties[key];
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
this._core.store.state.objectsMap.update(this.object);
|
|
49
51
|
this._core.updateObjectInDatabase(this.object);
|
|
50
52
|
}
|
|
51
53
|
}
|
|
@@ -343,20 +345,6 @@ class ObjectHelper {
|
|
|
343
345
|
static generateUUID() {
|
|
344
346
|
return Math.random().toString(36).substr(2, 9);
|
|
345
347
|
}
|
|
346
|
-
static clone(objOrObjs) {
|
|
347
|
-
const cloneObject = (obj) => {
|
|
348
|
-
const { _core, _elementRef, totalWidth, totalHeight, element, ...remainingProps } = obj;
|
|
349
|
-
const clonedProps = structuredClone(remainingProps);
|
|
350
|
-
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
351
|
-
clonedProps.element = element.cloneNode(true);
|
|
352
|
-
}
|
|
353
|
-
return clonedProps;
|
|
354
|
-
};
|
|
355
|
-
if (Array.isArray(objOrObjs)) {
|
|
356
|
-
return objOrObjs.map(cloneObject);
|
|
357
|
-
}
|
|
358
|
-
return cloneObject(objOrObjs);
|
|
359
|
-
}
|
|
360
348
|
static isEmpty(obj) {
|
|
361
349
|
if (obj === null || obj === undefined) {
|
|
362
350
|
return true;
|
|
@@ -597,6 +585,11 @@ class KritzelBaseObject {
|
|
|
597
585
|
rotate(value) {
|
|
598
586
|
this.rotation = value;
|
|
599
587
|
}
|
|
588
|
+
clone() {
|
|
589
|
+
const clone = new KritzelBaseObject();
|
|
590
|
+
Object.assign(clone, this);
|
|
591
|
+
return clone;
|
|
592
|
+
}
|
|
600
593
|
copy() {
|
|
601
594
|
const copiedObject = Object.create(Object.getPrototypeOf(this));
|
|
602
595
|
Object.assign(copiedObject, this);
|
|
@@ -608,9 +601,12 @@ class KritzelBaseObject {
|
|
|
608
601
|
// This method can be overridden by subclasses to handle click events when the object is selected.
|
|
609
602
|
}
|
|
610
603
|
serialize() {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
604
|
+
const { _core, _elementRef, element, totalWidth, totalHeight, ...remainingProps } = this;
|
|
605
|
+
const clonedProps = structuredClone(remainingProps);
|
|
606
|
+
if (element && typeof element === 'object' && 'nodeType' in element && element.nodeType === 1) {
|
|
607
|
+
clonedProps.element = element.cloneNode(true);
|
|
608
|
+
}
|
|
609
|
+
return clonedProps;
|
|
614
610
|
}
|
|
615
611
|
deserialize(object) {
|
|
616
612
|
Object.assign(this, object);
|
|
@@ -1440,10 +1436,18 @@ class MoveSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1440
1436
|
}
|
|
1441
1437
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1442
1438
|
this._core.store.state.selectionGroup.move(this.startX, this.startY, this.endX, this.endY);
|
|
1439
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1440
|
+
this._core.store.state.objectsMap.update(object);
|
|
1441
|
+
this._core.updateObjectInDatabase(object);
|
|
1442
|
+
});
|
|
1443
1443
|
}
|
|
1444
1444
|
undo() {
|
|
1445
1445
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1446
1446
|
this._core.store.state.selectionGroup.move(this.endX, this.endY, this.startX, this.startY);
|
|
1447
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1448
|
+
this._core.store.state.objectsMap.update(object);
|
|
1449
|
+
this._core.updateObjectInDatabase(object);
|
|
1450
|
+
});
|
|
1447
1451
|
}
|
|
1448
1452
|
}
|
|
1449
1453
|
|
|
@@ -1461,9 +1465,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1461
1465
|
startY;
|
|
1462
1466
|
endX;
|
|
1463
1467
|
endY;
|
|
1468
|
+
hasMoved = false;
|
|
1464
1469
|
constructor(core) {
|
|
1465
1470
|
super(core);
|
|
1466
1471
|
}
|
|
1472
|
+
reset() {
|
|
1473
|
+
this.dragStartX = 0;
|
|
1474
|
+
this.dragStartY = 0;
|
|
1475
|
+
this.startX = 0;
|
|
1476
|
+
this.startY = 0;
|
|
1477
|
+
this.endX = 0;
|
|
1478
|
+
this.endY = 0;
|
|
1479
|
+
this.hasMoved = false;
|
|
1480
|
+
}
|
|
1467
1481
|
handlePointerDown(event) {
|
|
1468
1482
|
if (event.pointerType === 'mouse') {
|
|
1469
1483
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
@@ -1502,16 +1516,21 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1502
1516
|
this._core.store.state.selectionGroup.move(clientX, clientY, this.dragStartX, this.dragStartY);
|
|
1503
1517
|
this.dragStartX = clientX;
|
|
1504
1518
|
this.dragStartY = clientY;
|
|
1519
|
+
this.hasMoved = true;
|
|
1505
1520
|
}
|
|
1506
1521
|
}
|
|
1507
1522
|
if (event.pointerType === 'touch') {
|
|
1508
1523
|
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
1509
|
-
if (this._core.store.state.pointers.size === 1 &&
|
|
1524
|
+
if (this._core.store.state.pointers.size === 1 &&
|
|
1525
|
+
this._core.store.state.selectionGroup &&
|
|
1526
|
+
!this._core.store.state.isResizeHandleSelected &&
|
|
1527
|
+
!this._core.store.state.isRotationHandleSelected) {
|
|
1510
1528
|
const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
|
|
1511
1529
|
const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
|
|
1512
1530
|
this._core.store.setState('isDragging', true);
|
|
1513
1531
|
this.endX = x;
|
|
1514
1532
|
this.endY = y;
|
|
1533
|
+
this.hasMoved = true;
|
|
1515
1534
|
const moveDeltaX = Math.abs(x - this.startX);
|
|
1516
1535
|
const moveDeltaY = Math.abs(y - this.startY);
|
|
1517
1536
|
const moveThreshold = 5;
|
|
@@ -1528,27 +1547,19 @@ class KritzelMoveHandler extends KritzelBaseHandler {
|
|
|
1528
1547
|
if (event.pointerType === 'mouse') {
|
|
1529
1548
|
if (this._core.store.state.isDragging) {
|
|
1530
1549
|
this._core.store.setState('isDragging', false);
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
translateY: object.translateY
|
|
1536
|
-
});
|
|
1537
|
-
});
|
|
1538
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1550
|
+
if (this.hasMoved) {
|
|
1551
|
+
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1552
|
+
}
|
|
1553
|
+
this.reset();
|
|
1539
1554
|
}
|
|
1540
1555
|
}
|
|
1541
1556
|
if (event.pointerType === 'touch') {
|
|
1542
1557
|
if (this._core.store.state.isDragging) {
|
|
1543
1558
|
this._core.store.setState('isDragging', false);
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
translateY: object.translateY
|
|
1549
|
-
});
|
|
1550
|
-
});
|
|
1551
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [moveSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1559
|
+
if (this.hasMoved) {
|
|
1560
|
+
this._core.history.executeCommand(new MoveSelectionGroupCommand(this._core, this, this.endX, this.endY, this.startX, this.startY, true));
|
|
1561
|
+
}
|
|
1562
|
+
this.reset();
|
|
1552
1563
|
}
|
|
1553
1564
|
}
|
|
1554
1565
|
}
|
|
@@ -1575,10 +1586,18 @@ class ResizeSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1575
1586
|
execute() {
|
|
1576
1587
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1577
1588
|
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
1589
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1590
|
+
this._core.store.state.objectsMap.update(object);
|
|
1591
|
+
this._core.updateObjectInDatabase(object);
|
|
1592
|
+
});
|
|
1578
1593
|
}
|
|
1579
1594
|
undo() {
|
|
1580
1595
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1581
1596
|
this._core.store.state.selectionGroup.resize(this.previousSize.x, this.previousSize.y, this.previousSize.width, this.previousSize.height);
|
|
1597
|
+
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1598
|
+
this._core.store.state.objectsMap.update(object);
|
|
1599
|
+
this._core.updateObjectInDatabase(object);
|
|
1600
|
+
});
|
|
1582
1601
|
}
|
|
1583
1602
|
}
|
|
1584
1603
|
|
|
@@ -1590,6 +1609,12 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1590
1609
|
constructor(core) {
|
|
1591
1610
|
super(core);
|
|
1592
1611
|
}
|
|
1612
|
+
reset() {
|
|
1613
|
+
this.initialMouseX = 0;
|
|
1614
|
+
this.initialMouseY = 0;
|
|
1615
|
+
this.initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1616
|
+
this.newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
1617
|
+
}
|
|
1593
1618
|
handlePointerDown(event) {
|
|
1594
1619
|
if (event.pointerType === 'mouse') {
|
|
1595
1620
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
@@ -1709,22 +1734,16 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
1709
1734
|
handlePointerUp(event) {
|
|
1710
1735
|
if (event.pointerType === 'mouse') {
|
|
1711
1736
|
if (this._core.store.state.isResizing) {
|
|
1712
|
-
|
|
1713
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1714
|
-
return new UpdateObjectCommand(this._core, this, object, { ...object });
|
|
1715
|
-
});
|
|
1716
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1737
|
+
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1717
1738
|
this._core.store.setState('isResizing', false);
|
|
1739
|
+
this.reset();
|
|
1718
1740
|
}
|
|
1719
1741
|
}
|
|
1720
1742
|
if (event.pointerType === 'touch') {
|
|
1721
1743
|
if (this._core.store.state.isResizing) {
|
|
1722
|
-
|
|
1723
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1724
|
-
return new UpdateObjectCommand(this._core, this, object, { ...object });
|
|
1725
|
-
});
|
|
1726
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1744
|
+
this._core.history.executeCommand(new ResizeSelectionGroupCommand(this._core, this, structuredClone(this.initialSize), structuredClone(this.newSize)));
|
|
1727
1745
|
this._core.store.setState('isResizing', false);
|
|
1746
|
+
this.reset();
|
|
1728
1747
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1729
1748
|
}
|
|
1730
1749
|
}
|
|
@@ -1735,10 +1754,10 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1735
1754
|
rotation;
|
|
1736
1755
|
initialRotation;
|
|
1737
1756
|
selectionGroup;
|
|
1738
|
-
constructor(core, initiator, rotation, skipHistory = false) {
|
|
1757
|
+
constructor(core, initiator, rotation, initialRotation, skipHistory = false) {
|
|
1739
1758
|
super(core, initiator, skipHistory);
|
|
1740
1759
|
this.rotation = rotation;
|
|
1741
|
-
this.initialRotation =
|
|
1760
|
+
this.initialRotation = initialRotation;
|
|
1742
1761
|
this.selectionGroup = this._core.store.state.selectionGroup;
|
|
1743
1762
|
}
|
|
1744
1763
|
execute() {
|
|
@@ -1746,13 +1765,15 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1746
1765
|
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
1747
1766
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1748
1767
|
this._core.store.state.objectsMap.update(object);
|
|
1768
|
+
this._core.updateObjectInDatabase(object);
|
|
1749
1769
|
});
|
|
1750
1770
|
}
|
|
1751
1771
|
undo() {
|
|
1752
1772
|
this._core.store.setState('selectionGroup', this.selectionGroup);
|
|
1753
|
-
this._core.store.state.selectionGroup.rotate(this.
|
|
1773
|
+
this._core.store.state.selectionGroup.rotate(this.initialRotation);
|
|
1754
1774
|
this._core.store.state.selectionGroup.objects.forEach(object => {
|
|
1755
1775
|
this._core.store.state.objectsMap.update(object);
|
|
1776
|
+
this._core.updateObjectInDatabase(object);
|
|
1756
1777
|
});
|
|
1757
1778
|
}
|
|
1758
1779
|
}
|
|
@@ -1760,9 +1781,16 @@ class RotateSelectionGroupCommand extends KritzelBaseCommand {
|
|
|
1760
1781
|
class KritzelRotationHandler extends KritzelBaseHandler {
|
|
1761
1782
|
initialRotation = 0;
|
|
1762
1783
|
rotation = 0;
|
|
1784
|
+
unchangedObjects = [];
|
|
1785
|
+
initialSelectionGroupRotation = 0;
|
|
1763
1786
|
constructor(core) {
|
|
1764
1787
|
super(core);
|
|
1765
1788
|
}
|
|
1789
|
+
reset() {
|
|
1790
|
+
this.initialRotation = 0;
|
|
1791
|
+
this.rotation = 0;
|
|
1792
|
+
this.unchangedObjects = [];
|
|
1793
|
+
}
|
|
1766
1794
|
handlePointerDown(event) {
|
|
1767
1795
|
if (event.pointerType === 'mouse') {
|
|
1768
1796
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
@@ -1774,7 +1802,9 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1774
1802
|
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
1775
1803
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1776
1804
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1805
|
+
this.initialSelectionGroupRotation = this._core.store.state.selectionGroup.rotation;
|
|
1777
1806
|
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
1807
|
+
this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
|
|
1778
1808
|
}
|
|
1779
1809
|
}
|
|
1780
1810
|
}
|
|
@@ -1794,6 +1824,7 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1794
1824
|
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
1795
1825
|
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
1796
1826
|
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
1827
|
+
this.unchangedObjects = this._core.store.state.selectionGroup.objects.map(obj => obj.clone());
|
|
1797
1828
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1798
1829
|
}
|
|
1799
1830
|
}
|
|
@@ -1836,32 +1867,16 @@ class KritzelRotationHandler extends KritzelBaseHandler {
|
|
|
1836
1867
|
handlePointerUp(event) {
|
|
1837
1868
|
if (event.pointerType === 'mouse') {
|
|
1838
1869
|
if (this._core.store.state.isRotating) {
|
|
1839
|
-
|
|
1840
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1841
|
-
return new UpdateObjectCommand(this._core, this, object, {
|
|
1842
|
-
rotation: object.rotation,
|
|
1843
|
-
translateX: object.translateX,
|
|
1844
|
-
translateY: object.translateY,
|
|
1845
|
-
});
|
|
1846
|
-
});
|
|
1847
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1870
|
+
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1848
1871
|
this._core.store.setState('isRotating', false);
|
|
1849
|
-
this.
|
|
1850
|
-
this.rotation = 0;
|
|
1872
|
+
this.reset();
|
|
1851
1873
|
}
|
|
1852
1874
|
}
|
|
1853
1875
|
if (event.pointerType === 'touch') {
|
|
1854
1876
|
if (this._core.store.state.isRotating) {
|
|
1855
|
-
|
|
1856
|
-
const updateObjectsCommand = this._core.store.state.selectionGroup.objects.map(object => {
|
|
1857
|
-
return new UpdateObjectCommand(this._core, this, object, {
|
|
1858
|
-
rotation: object.rotation,
|
|
1859
|
-
});
|
|
1860
|
-
});
|
|
1861
|
-
this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
1877
|
+
this._core.history.executeCommand(new RotateSelectionGroupCommand(this._core, this, this.rotation, this.initialSelectionGroupRotation));
|
|
1862
1878
|
this._core.store.setState('isRotating', false);
|
|
1863
|
-
this.
|
|
1864
|
-
this.rotation = 0;
|
|
1879
|
+
this.reset();
|
|
1865
1880
|
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
1866
1881
|
}
|
|
1867
1882
|
}
|
|
@@ -2494,7 +2509,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2494
2509
|
else {
|
|
2495
2510
|
this.objects.splice(index, 1);
|
|
2496
2511
|
}
|
|
2497
|
-
this.unchangedObjects =
|
|
2512
|
+
this.unchangedObjects = this.objects.map(obj => obj.clone());
|
|
2498
2513
|
this.refreshObjectDimensions();
|
|
2499
2514
|
}
|
|
2500
2515
|
deselectAllChildren() {
|
|
@@ -2545,7 +2560,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2545
2560
|
this._core.store.state.objectsMap.update(child);
|
|
2546
2561
|
});
|
|
2547
2562
|
this.refreshObjectDimensions();
|
|
2548
|
-
this.unchangedObjects =
|
|
2563
|
+
this.unchangedObjects = this.objects.map(obj => obj.clone());
|
|
2549
2564
|
}
|
|
2550
2565
|
rotate(value) {
|
|
2551
2566
|
this.rotation = value;
|
|
@@ -2575,7 +2590,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
2575
2590
|
selectionGroup.addOrRemove(copiedObject);
|
|
2576
2591
|
currentZIndex++;
|
|
2577
2592
|
});
|
|
2578
|
-
selectionGroup.unchangedObjects =
|
|
2593
|
+
selectionGroup.unchangedObjects = selectionGroup.objects.map(obj => obj.clone());
|
|
2579
2594
|
if (this.objects.length === 1) {
|
|
2580
2595
|
selectionGroup.rotation = this.objects[0].rotation;
|
|
2581
2596
|
}
|
|
@@ -2740,6 +2755,6 @@ exports.ObjectHelper = ObjectHelper;
|
|
|
2740
2755
|
exports.RemoveObjectCommand = RemoveObjectCommand;
|
|
2741
2756
|
exports.RemoveSelectionGroupCommand = RemoveSelectionGroupCommand;
|
|
2742
2757
|
exports.UpdateObjectCommand = UpdateObjectCommand;
|
|
2743
|
-
//# sourceMappingURL=index-
|
|
2758
|
+
//# sourceMappingURL=index-DCHCVnOl.js.map
|
|
2744
2759
|
|
|
2745
|
-
//# sourceMappingURL=index-
|
|
2760
|
+
//# sourceMappingURL=index-DCHCVnOl.js.map
|