kritzel-stencil 0.0.131 → 0.0.132
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-nzUNdMPh.js +6 -2
- package/dist/cjs/{index-BwINBV6L.js → index-ouFX0OVi.js} +715 -676
- package/dist/cjs/index-ouFX0OVi.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-brush-style.cjs.entry.js +32 -0
- package/dist/cjs/kritzel-brush-style.entry.cjs.js.map +1 -0
- package/dist/cjs/{kritzel-brush-style_23.cjs.entry.js → kritzel-color_22.cjs.entry.js} +1044 -873
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/stencil.cjs.js +1 -1
- package/dist/collection/classes/commands/add-object.command.js +6 -7
- package/dist/collection/classes/commands/add-object.command.js.map +1 -1
- package/dist/collection/classes/commands/add-selection-group.command.js +9 -9
- package/dist/collection/classes/commands/add-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/base.command.js +3 -3
- package/dist/collection/classes/commands/base.command.js.map +1 -1
- package/dist/collection/classes/commands/batch.command.js +2 -2
- package/dist/collection/classes/commands/batch.command.js.map +1 -1
- package/dist/collection/classes/commands/move-selection-group.command.js +7 -7
- package/dist/collection/classes/commands/move-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-object.command.js +8 -9
- package/dist/collection/classes/commands/remove-object.command.js.map +1 -1
- package/dist/collection/classes/commands/remove-selection-group.command.js +7 -7
- package/dist/collection/classes/commands/remove-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/resize-selection-group.command.js +7 -7
- package/dist/collection/classes/commands/resize-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/rotate-selection-group.command.js +12 -12
- package/dist/collection/classes/commands/rotate-selection-group.command.js.map +1 -1
- package/dist/collection/classes/commands/update-object.command.js +4 -5
- package/dist/collection/classes/commands/update-object.command.js.map +1 -1
- package/dist/collection/classes/commands/update-viewport.command.js +11 -11
- package/dist/collection/classes/commands/update-viewport.command.js.map +1 -1
- package/dist/collection/classes/{store.class.js → core/core.class.js} +120 -145
- package/dist/collection/classes/core/core.class.js.map +1 -0
- package/dist/collection/classes/{database.class.js → core/database.class.js} +28 -20
- package/dist/collection/classes/core/database.class.js.map +1 -0
- package/dist/collection/classes/core/history.class.js +88 -0
- package/dist/collection/classes/core/history.class.js.map +1 -0
- package/dist/collection/classes/{reviver.class.js → core/reviver.class.js} +27 -23
- package/dist/collection/classes/core/reviver.class.js.map +1 -0
- package/dist/collection/classes/core/store.class.js +51 -0
- package/dist/collection/classes/core/store.class.js.map +1 -0
- package/dist/collection/classes/core/viewport.class.js +165 -0
- package/dist/collection/classes/core/viewport.class.js.map +1 -0
- package/dist/collection/classes/core/workspace.class.js +42 -0
- package/dist/collection/classes/core/workspace.class.js.map +1 -0
- package/dist/collection/classes/handlers/base.handler.js +4 -4
- package/dist/collection/classes/handlers/base.handler.js.map +1 -1
- package/dist/collection/classes/handlers/context-menu.handler.js +24 -19
- package/dist/collection/classes/handlers/context-menu.handler.js.map +1 -1
- package/dist/collection/classes/handlers/hover.handler.js +5 -5
- package/dist/collection/classes/handlers/hover.handler.js.map +1 -1
- package/dist/collection/classes/handlers/key.handler.js +38 -44
- package/dist/collection/classes/handlers/key.handler.js.map +1 -1
- package/dist/collection/classes/handlers/move.handler.js +34 -34
- package/dist/collection/classes/handlers/move.handler.js.map +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +53 -56
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/handlers/rotation.handler.js +53 -55
- package/dist/collection/classes/handlers/rotation.handler.js.map +1 -1
- package/dist/collection/classes/handlers/selection.handler.js +73 -72
- package/dist/collection/classes/handlers/selection.handler.js.map +1 -1
- package/dist/collection/classes/objects/base-object.class.js +22 -17
- package/dist/collection/classes/objects/base-object.class.js.map +1 -1
- package/dist/collection/classes/objects/custom-element.class.js +3 -3
- package/dist/collection/classes/objects/custom-element.class.js.map +1 -1
- package/dist/collection/classes/objects/image.class.js +5 -5
- package/dist/collection/classes/objects/image.class.js.map +1 -1
- package/dist/collection/classes/objects/path.class.js +7 -7
- package/dist/collection/classes/objects/path.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-box.class.js +4 -4
- package/dist/collection/classes/objects/selection-box.class.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +16 -16
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/collection/classes/objects/text.class.js +13 -13
- package/dist/collection/classes/objects/text.class.js.map +1 -1
- package/dist/collection/classes/registries/tool.registry.js +2 -2
- package/dist/collection/classes/registries/tool.registry.js.map +1 -1
- package/dist/collection/classes/tools/base-tool.class.js +11 -5
- package/dist/collection/classes/tools/base-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/brush-tool.class.js +57 -53
- package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/eraser-tool.class.js +26 -26
- package/dist/collection/classes/tools/eraser-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/image-tool.class.js +11 -11
- package/dist/collection/classes/tools/image-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/selection-tool.class.js +39 -37
- package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
- package/dist/collection/classes/tools/text-tool.class.js +37 -37
- package/dist/collection/classes/tools/text-tool.class.js.map +1 -1
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js +28 -28
- package/dist/collection/components/core/kritzel-cursor-trail/kritzel-cursor-trail.js.map +1 -1
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.css +7 -9
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js +177 -7
- package/dist/collection/components/core/kritzel-editor/kritzel-editor.js.map +1 -1
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +236 -233
- package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js +1 -1
- package/dist/collection/components/shared/kritzel-brush-style/kritzel-brush-style.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js +2 -2
- package/dist/collection/components/shared/kritzel-color/kritzel-color.js.map +1 -1
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.css +5 -0
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js +3 -3
- package/dist/collection/components/shared/kritzel-color-palette/kritzel-color-palette.js.map +1 -1
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js +12 -12
- package/dist/collection/components/shared/kritzel-dropdown/kritzel-dropdown.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js +1 -1
- package/dist/collection/components/shared/kritzel-font/kritzel-font.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js +1 -1
- package/dist/collection/components/shared/kritzel-font-family/kritzel-font-family.js.map +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js +1 -1
- package/dist/collection/components/shared/kritzel-font-size/kritzel-font-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.css +1 -0
- package/dist/collection/components/shared/kritzel-icon/kritzel-icon.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.css +5 -1
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js +2 -2
- package/dist/collection/components/shared/kritzel-menu/kritzel-menu.js.map +1 -1
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.css +18 -7
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js +24 -9
- package/dist/collection/components/shared/kritzel-menu-item/kritzel-menu-item.js.map +1 -1
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js +4 -42
- package/dist/collection/components/shared/kritzel-portal/kritzel-portal.js.map +1 -1
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.css +0 -4
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js +52 -10
- package/dist/collection/components/shared/kritzel-split-button/kritzel-split-button.js.map +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.css +4 -0
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js +1 -1
- package/dist/collection/components/shared/kritzel-stroke-size/kritzel-stroke-size.js.map +1 -1
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js +79 -7
- package/dist/collection/components/shared/kritzel-tooltip/kritzel-tooltip.js.map +1 -1
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js +47 -15
- package/dist/collection/components/ui/kritzel-context-menu/kritzel-context-menu.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.css +4 -0
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js +6 -6
- package/dist/collection/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js +2 -2
- package/dist/collection/components/ui/kritzel-control-text-config/kritzel-control-text-config.js.map +1 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.css +12 -1
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js +23 -7
- package/dist/collection/components/ui/kritzel-controls/kritzel-controls.js.map +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.css +5 -0
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js +1 -1
- package/dist/collection/components/ui/kritzel-utility-panel/kritzel-utility-panel.js.map +1 -1
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js +25 -15
- package/dist/collection/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.js.map +1 -1
- package/dist/collection/configs/default-engine-state.js +0 -1
- package/dist/collection/configs/default-engine-state.js.map +1 -1
- package/dist/collection/helpers/devices.helper.js +20 -0
- package/dist/collection/helpers/devices.helper.js.map +1 -1
- package/dist/collection/helpers/event.helper.js +1 -5
- package/dist/collection/helpers/event.helper.js.map +1 -1
- package/dist/collection/helpers/html.helper.js +29 -0
- package/dist/collection/helpers/html.helper.js.map +1 -1
- package/dist/collection/helpers/object.helper.js +1 -1
- package/dist/collection/helpers/object.helper.js.map +1 -1
- package/dist/collection/index.js +1 -1
- package/dist/collection/index.js.map +1 -1
- package/dist/collection/interfaces/engine-state.interface.js.map +1 -1
- package/dist/collection/interfaces/serializable.interface.js.map +1 -1
- package/dist/collection/types/deep-readonly.type.js +2 -0
- package/dist/collection/types/deep-readonly.type.js.map +1 -0
- package/dist/components/index.js +3 -3
- package/dist/components/kritzel-brush-style.js +59 -1
- 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 +80 -37
- 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-CMJ3P0Vw.js → p-0iJh9Z6m.js} +5 -5
- package/dist/components/p-0iJh9Z6m.js.map +1 -0
- package/dist/components/{p-DHSEK3rF.js → p-B3VQubt_.js} +164 -153
- package/dist/components/p-B3VQubt_.js.map +1 -0
- package/dist/components/{p-BB0_-X42.js → p-B7kZ1_RH.js} +4 -4
- package/dist/components/{p-BB0_-X42.js.map → p-B7kZ1_RH.js.map} +1 -1
- package/dist/components/{p-t4NIsuX9.js → p-B7w19kIk.js} +15 -27
- package/dist/components/p-B7w19kIk.js.map +1 -0
- package/dist/components/{p-B1BLgWL1.js → p-BGdsAz54.js} +27 -18
- package/dist/components/p-BGdsAz54.js.map +1 -0
- package/dist/components/{p-BhiYvSBc.js → p-BM9IjvnD.js} +3 -3
- package/dist/components/p-BM9IjvnD.js.map +1 -0
- package/dist/components/{p-BrBQUN0Q.js → p-BPsQrpzN.js} +40 -11
- package/dist/components/p-BPsQrpzN.js.map +1 -0
- package/dist/components/{p-BB5R2k1o.js → p-BiCgeOiJ.js} +41 -31
- package/dist/components/p-BiCgeOiJ.js.map +1 -0
- package/dist/components/{p-CGmS8wnN.js → p-C1-nvBx9.js} +26 -16
- package/dist/components/p-C1-nvBx9.js.map +1 -0
- package/dist/components/p-C6qB08BS.js +68 -0
- package/dist/components/p-C6qB08BS.js.map +1 -0
- package/dist/components/{p-DxTu1aoJ.js → p-CTvJDYFQ.js} +7 -45
- package/dist/components/p-CTvJDYFQ.js.map +1 -0
- package/dist/components/{p-DMrtdhBD.js → p-CsyM5q2M.js} +7 -7
- package/dist/components/p-CsyM5q2M.js.map +1 -0
- package/dist/components/{p-BPz_H-EG.js → p-CvmWmUK9.js} +28 -16
- package/dist/components/p-CvmWmUK9.js.map +1 -0
- package/dist/components/{p-BgmKrd5Z.js → p-DCx3703u.js} +5 -5
- package/dist/components/p-DCx3703u.js.map +1 -0
- package/dist/components/{p-trncBp_6.js → p-DFO-6kuA.js} +15 -15
- package/dist/components/p-DFO-6kuA.js.map +1 -0
- package/dist/components/{p-BeljsQ-8.js → p-D_907-Wd.js} +32 -17
- package/dist/components/p-D_907-Wd.js.map +1 -0
- package/dist/components/{p-BuewJQNl.js → p-Davd1R_4.js} +1111 -1085
- package/dist/components/p-Davd1R_4.js.map +1 -0
- package/dist/components/{p-BubxwvMA.js → p-Db3kxVe2.js} +24 -24
- package/dist/components/p-Db3kxVe2.js.map +1 -0
- package/dist/components/{p-BexTdWaX.js → p-Ddlbt3Bj.js} +4 -4
- package/dist/components/p-Ddlbt3Bj.js.map +1 -0
- package/dist/components/{p-CHxPWeZd.js → p-DjU7p3od.js} +11 -11
- package/dist/components/{p-CHxPWeZd.js.map → p-DjU7p3od.js.map} +1 -1
- package/dist/components/{p-DnUKql15.js → p-EXPChOF6.js} +3 -3
- package/dist/components/{p-DnUKql15.js.map → p-EXPChOF6.js.map} +1 -1
- package/dist/components/p-YqK8ch2R.js +46 -0
- package/dist/components/p-YqK8ch2R.js.map +1 -0
- package/dist/components/p-l10It7Nm.js +30 -0
- package/dist/components/p-l10It7Nm.js.map +1 -0
- package/dist/components/{p-p1Jkec_q.js → p-sq9jgfX0.js} +3 -3
- package/dist/components/p-sq9jgfX0.js.map +1 -0
- package/dist/components/{p-yZ48g7-u.js → p-sreNwi0N.js} +4 -4
- package/dist/components/{p-yZ48g7-u.js.map → p-sreNwi0N.js.map} +1 -1
- package/dist/esm/{index-B-oSk-v8.js → index-C_uHp-ur.js} +716 -677
- package/dist/esm/index-C_uHp-ur.js.map +1 -0
- package/dist/esm/index-oCOlsFCN.js +6 -2
- package/dist/esm/index.js +1 -1
- package/dist/esm/kritzel-brush-style.entry.js +30 -0
- package/dist/esm/kritzel-brush-style.entry.js.map +1 -0
- package/dist/esm/{kritzel-brush-style_23.entry.js → kritzel-color_22.entry.js} +1046 -874
- 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 -0
- package/dist/stencil/p-25d1e040.entry.js +2 -0
- package/dist/stencil/p-25d1e040.entry.js.map +1 -0
- package/dist/stencil/p-C_uHp-ur.js +2 -0
- package/dist/stencil/p-C_uHp-ur.js.map +1 -0
- package/dist/stencil/p-a6f8283e.entry.js +2 -0
- package/dist/stencil/p-a6f8283e.entry.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/commands/add-object.command.d.ts +2 -2
- package/dist/types/classes/commands/add-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/base.command.d.ts +3 -3
- package/dist/types/classes/commands/batch.command.d.ts +2 -1
- package/dist/types/classes/commands/move-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/remove-object.command.d.ts +2 -2
- package/dist/types/classes/commands/remove-selection-group.command.d.ts +2 -2
- package/dist/types/classes/commands/resize-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/rotate-selection-group.command.d.ts +2 -1
- package/dist/types/classes/commands/update-object.command.d.ts +2 -2
- package/dist/types/classes/commands/update-viewport.command.d.ts +2 -1
- package/dist/types/classes/{store.class.d.ts → core/core.class.d.ts} +9 -19
- package/dist/types/classes/{database.class.d.ts → core/database.class.d.ts} +3 -2
- package/dist/types/classes/{history.class.d.ts → core/history.class.d.ts} +5 -5
- package/dist/types/classes/core/reviver.class.d.ts +6 -0
- package/dist/types/classes/core/store.class.d.ts +17 -0
- package/dist/types/classes/{viewport.class.d.ts → core/viewport.class.d.ts} +3 -3
- package/dist/types/classes/core/workspace.class.d.ts +24 -0
- package/dist/types/classes/handlers/base.handler.d.ts +3 -3
- package/dist/types/classes/handlers/context-menu.handler.d.ts +2 -2
- package/dist/types/classes/handlers/hover.handler.d.ts +2 -2
- package/dist/types/classes/handlers/key.handler.d.ts +2 -2
- package/dist/types/classes/handlers/move.handler.d.ts +2 -2
- package/dist/types/classes/handlers/resize.handler.d.ts +2 -2
- package/dist/types/classes/handlers/rotation.handler.d.ts +2 -2
- package/dist/types/classes/handlers/selection.handler.d.ts +2 -2
- package/dist/types/classes/objects/base-object.class.d.ts +5 -4
- package/dist/types/classes/objects/custom-element.class.d.ts +2 -2
- package/dist/types/classes/objects/image.class.d.ts +2 -2
- package/dist/types/classes/objects/path.class.d.ts +2 -2
- package/dist/types/classes/objects/selection-box.class.d.ts +2 -2
- package/dist/types/classes/objects/selection-group.class.d.ts +2 -2
- package/dist/types/classes/objects/text.class.d.ts +2 -2
- package/dist/types/classes/registries/tool.registry.d.ts +2 -2
- package/dist/types/classes/tools/base-tool.class.d.ts +8 -4
- package/dist/types/classes/tools/brush-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/eraser-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/image-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/selection-tool.class.d.ts +2 -2
- package/dist/types/classes/tools/text-tool.class.d.ts +2 -2
- package/dist/types/components/core/kritzel-cursor-trail/kritzel-cursor-trail.d.ts +5 -5
- package/dist/types/components/core/kritzel-editor/kritzel-editor.d.ts +13 -3
- package/dist/types/components/core/kritzel-engine/kritzel-engine.d.ts +21 -22
- package/dist/types/components/shared/kritzel-dropdown/kritzel-dropdown.d.ts +2 -2
- package/dist/types/components/shared/kritzel-menu-item/kritzel-menu-item.d.ts +2 -0
- package/dist/types/components/shared/kritzel-portal/kritzel-portal.d.ts +0 -1
- package/dist/types/components/shared/kritzel-split-button/kritzel-split-button.d.ts +4 -2
- package/dist/types/components/shared/kritzel-tooltip/kritzel-tooltip.d.ts +8 -2
- package/dist/types/components/ui/kritzel-context-menu/kritzel-context-menu.d.ts +5 -3
- package/dist/types/components/ui/kritzel-control-brush-config/kritzel-control-brush-config.d.ts +1 -1
- package/dist/types/components/ui/kritzel-controls/kritzel-controls.d.ts +3 -1
- package/dist/types/components/ui/kritzel-workspace-manager/kritzel-workspace-manager.d.ts +3 -2
- package/dist/types/components.d.ts +41 -12
- package/dist/types/helpers/devices.helper.d.ts +4 -0
- package/dist/types/helpers/event.helper.d.ts +1 -1
- package/dist/types/helpers/html.helper.d.ts +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/interfaces/engine-state.interface.d.ts +1 -2
- package/dist/types/interfaces/serializable.interface.d.ts +2 -1
- package/dist/types/types/deep-readonly.type.d.ts +7 -0
- package/package.json +64 -63
- package/dist/cjs/index-BwINBV6L.js.map +0 -1
- package/dist/collection/classes/database.class.js.map +0 -1
- package/dist/collection/classes/history.class.js +0 -88
- package/dist/collection/classes/history.class.js.map +0 -1
- package/dist/collection/classes/reviver.class.js.map +0 -1
- package/dist/collection/classes/store.class.js.map +0 -1
- package/dist/collection/classes/viewport.class.js +0 -153
- package/dist/collection/classes/viewport.class.js.map +0 -1
- package/dist/collection/classes/workspace.class.js +0 -15
- package/dist/collection/classes/workspace.class.js.map +0 -1
- package/dist/components/p-B1BLgWL1.js.map +0 -1
- package/dist/components/p-BB5R2k1o.js.map +0 -1
- package/dist/components/p-BPz_H-EG.js.map +0 -1
- package/dist/components/p-B_lb1FGi.js +0 -19
- package/dist/components/p-B_lb1FGi.js.map +0 -1
- package/dist/components/p-BeljsQ-8.js.map +0 -1
- package/dist/components/p-BexTdWaX.js.map +0 -1
- package/dist/components/p-BgmKrd5Z.js.map +0 -1
- package/dist/components/p-BhiYvSBc.js.map +0 -1
- package/dist/components/p-BrBQUN0Q.js.map +0 -1
- package/dist/components/p-BubxwvMA.js.map +0 -1
- package/dist/components/p-BuewJQNl.js.map +0 -1
- package/dist/components/p-CGmS8wnN.js.map +0 -1
- package/dist/components/p-CJKA5zIE.js +0 -10
- package/dist/components/p-CJKA5zIE.js.map +0 -1
- package/dist/components/p-CMJ3P0Vw.js.map +0 -1
- package/dist/components/p-DHSEK3rF.js.map +0 -1
- package/dist/components/p-DMrtdhBD.js.map +0 -1
- package/dist/components/p-DxTu1aoJ.js.map +0 -1
- package/dist/components/p-p1Jkec_q.js.map +0 -1
- package/dist/components/p-rIRXQdie.js +0 -64
- package/dist/components/p-rIRXQdie.js.map +0 -1
- package/dist/components/p-t4NIsuX9.js.map +0 -1
- package/dist/components/p-trncBp_6.js.map +0 -1
- package/dist/esm/index-B-oSk-v8.js.map +0 -1
- package/dist/stencil/p-3bb80782.entry.js +0 -2
- package/dist/stencil/p-3bb80782.entry.js.map +0 -1
- package/dist/stencil/p-B-oSk-v8.js +0 -2
- package/dist/stencil/p-B-oSk-v8.js.map +0 -1
- package/dist/types/classes/reviver.class.d.ts +0 -6
- package/dist/types/classes/workspace.class.d.ts +0 -16
|
@@ -9,71 +9,71 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
9
9
|
initialMouseY = 0;
|
|
10
10
|
initialSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
11
11
|
newSize = { x: 0, y: 0, width: 0, height: 0 };
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
12
|
+
constructor(core) {
|
|
13
|
+
super(core);
|
|
14
14
|
}
|
|
15
15
|
handlePointerDown(event) {
|
|
16
16
|
if (event.pointerType === 'mouse') {
|
|
17
17
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
18
|
-
if (this.
|
|
19
|
-
const clientX = event.clientX - this.
|
|
20
|
-
const clientY = event.clientY - this.
|
|
21
|
-
this.
|
|
18
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
19
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
20
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
21
|
+
this._core.store.setState('isResizing', true);
|
|
22
22
|
this.initialMouseX = clientX;
|
|
23
23
|
this.initialMouseY = clientY;
|
|
24
|
-
this.initialSize.width = this.
|
|
25
|
-
this.initialSize.height = this.
|
|
26
|
-
this.initialSize.x = this.
|
|
27
|
-
this.initialSize.y = this.
|
|
24
|
+
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
25
|
+
this.initialSize.height = this._core.store.state.selectionGroup.height;
|
|
26
|
+
this.initialSize.x = this._core.store.state.selectionGroup.translateX;
|
|
27
|
+
this.initialSize.y = this._core.store.state.selectionGroup.translateY;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
if (event.pointerType === 'touch') {
|
|
32
|
-
const activePointers = Array.from(this.
|
|
32
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
33
33
|
const firstTouch = activePointers[0];
|
|
34
34
|
if (!firstTouch) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
37
|
if (activePointers.length === 1) {
|
|
38
|
-
if (this.
|
|
39
|
-
const clientX = Math.round(firstTouch.clientX - this.
|
|
40
|
-
const clientY = Math.round(firstTouch.clientY - this.
|
|
41
|
-
this.
|
|
38
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isResizeHandleSelected) {
|
|
39
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
40
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
41
|
+
this._core.store.setState('isResizing', true);
|
|
42
42
|
this.initialMouseX = clientX;
|
|
43
43
|
this.initialMouseY = clientY;
|
|
44
|
-
this.initialSize.width = this.
|
|
45
|
-
this.initialSize.height = this.
|
|
46
|
-
this.initialSize.x = this.
|
|
47
|
-
this.initialSize.y = this.
|
|
48
|
-
clearTimeout(this.
|
|
44
|
+
this.initialSize.width = this._core.store.state.selectionGroup.width;
|
|
45
|
+
this.initialSize.height = this._core.store.state.selectionGroup.height;
|
|
46
|
+
this.initialSize.x = this._core.store.state.selectionGroup.translateX;
|
|
47
|
+
this.initialSize.y = this._core.store.state.selectionGroup.translateY;
|
|
48
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
handlePointerMove(event) {
|
|
54
54
|
if (event.pointerType === 'mouse') {
|
|
55
|
-
if (this.
|
|
56
|
-
const clientX = event.clientX - this.
|
|
57
|
-
const clientY = event.clientY - this.
|
|
55
|
+
if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {
|
|
56
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
57
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
58
58
|
const dx = clientX - this.initialMouseX;
|
|
59
59
|
const dy = clientY - this.initialMouseY;
|
|
60
|
-
switch (this.
|
|
60
|
+
switch (this._core.store.state.resizeHandleType) {
|
|
61
61
|
case KritzelHandleType.TopLeft:
|
|
62
62
|
this.newSize.width = this.initialSize.width - dx;
|
|
63
63
|
this.newSize.height = this.initialSize.height - dy;
|
|
64
|
-
this.newSize.x = dx / this.
|
|
65
|
-
this.newSize.y = dy / this.
|
|
64
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
65
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
66
66
|
break;
|
|
67
67
|
case KritzelHandleType.TopRight:
|
|
68
68
|
this.newSize.width = this.initialSize.width + dx;
|
|
69
69
|
this.newSize.height = this.initialSize.height - dy;
|
|
70
70
|
this.newSize.x = this.initialSize.x;
|
|
71
|
-
this.newSize.y = dy / this.
|
|
71
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
72
72
|
break;
|
|
73
73
|
case KritzelHandleType.BottomLeft:
|
|
74
74
|
this.newSize.width = this.initialSize.width - dx;
|
|
75
75
|
this.newSize.height = this.initialSize.height + dy;
|
|
76
|
-
this.newSize.x = dx / this.
|
|
76
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
77
77
|
this.newSize.y = this.initialSize.y;
|
|
78
78
|
break;
|
|
79
79
|
case KritzelHandleType.BottomRight:
|
|
@@ -83,38 +83,37 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
83
83
|
this.newSize.y = this.initialSize.y;
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
|
-
this.
|
|
87
|
-
this._store.rerender();
|
|
86
|
+
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
if (event.pointerType === 'touch') {
|
|
91
|
-
const activePointers = Array.from(this.
|
|
90
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
92
91
|
const oneFingerTouch = activePointers[0];
|
|
93
92
|
if (!oneFingerTouch) {
|
|
94
93
|
return;
|
|
95
94
|
}
|
|
96
|
-
if (this.
|
|
97
|
-
const clientX = Math.round(oneFingerTouch.clientX - this.
|
|
98
|
-
const clientY = Math.round(oneFingerTouch.clientY - this.
|
|
95
|
+
if (this._core.store.state.isResizing && this._core.store.state.selectionGroup) {
|
|
96
|
+
const clientX = Math.round(oneFingerTouch.clientX - this._core.store.offsetX);
|
|
97
|
+
const clientY = Math.round(oneFingerTouch.clientY - this._core.store.offsetY);
|
|
99
98
|
const dx = clientX - this.initialMouseX;
|
|
100
99
|
const dy = clientY - this.initialMouseY;
|
|
101
|
-
switch (this.
|
|
100
|
+
switch (this._core.store.state.resizeHandleType) {
|
|
102
101
|
case KritzelHandleType.TopLeft:
|
|
103
102
|
this.newSize.width = this.initialSize.width - dx;
|
|
104
103
|
this.newSize.height = this.initialSize.height - dy;
|
|
105
|
-
this.newSize.x = dx / this.
|
|
106
|
-
this.newSize.y = dy / this.
|
|
104
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
105
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
107
106
|
break;
|
|
108
107
|
case KritzelHandleType.TopRight:
|
|
109
108
|
this.newSize.width = this.initialSize.width + dx;
|
|
110
109
|
this.newSize.height = this.initialSize.height - dy;
|
|
111
110
|
this.newSize.x = this.initialSize.x;
|
|
112
|
-
this.newSize.y = dy / this.
|
|
111
|
+
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
113
112
|
break;
|
|
114
113
|
case KritzelHandleType.BottomLeft:
|
|
115
114
|
this.newSize.width = this.initialSize.width - dx;
|
|
116
115
|
this.newSize.height = this.initialSize.height + dy;
|
|
117
|
-
this.newSize.x = dx / this.
|
|
116
|
+
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
118
117
|
this.newSize.y = this.initialSize.y;
|
|
119
118
|
break;
|
|
120
119
|
case KritzelHandleType.BottomRight:
|
|
@@ -124,33 +123,31 @@ export class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
124
123
|
this.newSize.y = this.initialSize.y;
|
|
125
124
|
break;
|
|
126
125
|
}
|
|
127
|
-
this.
|
|
128
|
-
clearTimeout(this.
|
|
126
|
+
this._core.store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
127
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
129
128
|
}
|
|
130
129
|
}
|
|
131
130
|
}
|
|
132
131
|
handlePointerUp(event) {
|
|
133
132
|
if (event.pointerType === 'mouse') {
|
|
134
|
-
if (this.
|
|
135
|
-
const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this.
|
|
136
|
-
const updateObjectsCommand = this.
|
|
137
|
-
return new UpdateObjectCommand(this.
|
|
133
|
+
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 });
|
|
138
137
|
});
|
|
139
|
-
this.
|
|
140
|
-
this.
|
|
141
|
-
this._store.rerender();
|
|
138
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
139
|
+
this._core.store.setState('isResizing', false);
|
|
142
140
|
}
|
|
143
141
|
}
|
|
144
142
|
if (event.pointerType === 'touch') {
|
|
145
|
-
if (this.
|
|
146
|
-
const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this.
|
|
147
|
-
const updateObjectsCommand = this.
|
|
148
|
-
return new UpdateObjectCommand(this.
|
|
143
|
+
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 });
|
|
149
147
|
});
|
|
150
|
-
this.
|
|
151
|
-
this.
|
|
152
|
-
this.
|
|
153
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
148
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));
|
|
149
|
+
this._core.store.setState('isResizing', false);
|
|
150
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
154
151
|
}
|
|
155
152
|
}
|
|
156
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resize.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/resize.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,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,MAA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AAC,QAAQ,EAAE,CAAC;gBAEvB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import { KritzelHandleType } from '../../enums/handle-type.enum';\r\nimport { KritzelEventHelper } from '../../helpers/event.helper';\r\nimport { BatchCommand } from '../commands/batch.command';\r\nimport { ResizeSelectionGroupCommand } from '../commands/resize-selection-group.command';\r\nimport { UpdateObjectCommand } from '../commands/update-object.command';\r\nimport { KritzelStore } from '../store.class';\r\nimport { KritzelBaseHandler } from './base.handler';\r\n\r\nexport class KritzelResizeHandler extends KritzelBaseHandler {\r\n initialMouseX: number = 0;\r\n initialMouseY: number = 0;\r\n\r\n initialSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n newSize: { x: number; y: number; width: number; height: number } = { x: 0, y: 0, width: 0, height: 0 };\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._store.state.selectionGroup.width;\r\n this.initialSize.height = this._store.state.selectionGroup.height;\r\n this.initialSize.x = this._store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._store.state.selectionGroup.translateY;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._store.state.selectionGroup && this._store.state.isResizeHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n this._store.state.isResizing = true;\r\n this.initialMouseX = clientX;\r\n this.initialMouseY = clientY;\r\n this.initialSize.width = this._store.state.selectionGroup.width;\r\n this.initialSize.height = this._store.state.selectionGroup.height;\r\n this.initialSize.x = this._store.state.selectionGroup.translateX;\r\n this.initialSize.y = this._store.state.selectionGroup.translateY;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isResizing && this._store.state.selectionGroup) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n const oneFingerTouch = activePointers[0];\r\n\r\n if (!oneFingerTouch) {\r\n return;\r\n }\r\n\r\n if (this._store.state.isResizing && this._store.state.selectionGroup) {\r\n const clientX = Math.round(oneFingerTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(oneFingerTouch.clientY - this._store.offsetY);\r\n\r\n const dx = clientX - this.initialMouseX;\r\n const dy = clientY - this.initialMouseY;\r\n\r\n switch (this._store.state.resizeHandleType) {\r\n case KritzelHandleType.TopLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = dx / this._store.state.scale + this.initialSize.x;\r\n this.newSize.y = dy / this._store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.TopRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height - dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = dy / this._store.state.scale + this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomLeft:\r\n this.newSize.width = this.initialSize.width - dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = dx / this._store.state.scale + this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n case KritzelHandleType.BottomRight:\r\n this.newSize.width = this.initialSize.width + dx;\r\n this.newSize.height = this.initialSize.height + dy;\r\n this.newSize.x = this.initialSize.x;\r\n this.newSize.y = this.initialSize.y;\r\n break;\r\n }\r\n\r\n this._store.state.selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._store, this, object, { ...object });\r\n });\r\n\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));\r\n\r\n this._store.state.isResizing = false;\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isResizing) {\r\n const resizeSelectionGroupCommand = new ResizeSelectionGroupCommand(this._store, this, structuredClone(this.initialSize), structuredClone(this.newSize));\r\n const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._store, this, object, { ...object });\r\n });\r\n\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, [resizeSelectionGroupCommand, ...updateObjectsCommand]));\r\n this._store.state.isResizing = false;\r\n this._store.rerender();\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
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,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAExE,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,C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AG,IAAI,2BAA2B,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBACxJ,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACtF,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;gBAC1E,CAAC,CAAC,CAAC;gBAEH,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,2BAA2B,EAAE,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC;gBAC9H,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;gBAE/C,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"]}
|
|
@@ -6,111 +6,109 @@ import { BatchCommand } from "../commands/batch.command";
|
|
|
6
6
|
export class KritzelRotationHandler extends KritzelBaseHandler {
|
|
7
7
|
initialRotation = 0;
|
|
8
8
|
rotation = 0;
|
|
9
|
-
constructor(
|
|
10
|
-
super(
|
|
9
|
+
constructor(core) {
|
|
10
|
+
super(core);
|
|
11
11
|
}
|
|
12
12
|
handlePointerDown(event) {
|
|
13
13
|
if (event.pointerType === 'mouse') {
|
|
14
14
|
if (KritzelEventHelper.isLeftClick(event)) {
|
|
15
|
-
if (this.
|
|
16
|
-
const clientX = event.clientX - this.
|
|
17
|
-
const clientY = event.clientY - this.
|
|
18
|
-
this.
|
|
19
|
-
const centerX = this.
|
|
20
|
-
const centerY = this.
|
|
21
|
-
const cursorX = (clientX - this.
|
|
22
|
-
const cursorY = (clientY - this.
|
|
23
|
-
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this.
|
|
15
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
16
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
17
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
18
|
+
this._core.store.setState('isRotating', true);
|
|
19
|
+
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
20
|
+
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
21
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
22
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
23
|
+
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if (event.pointerType === 'touch') {
|
|
28
|
-
const activePointers = Array.from(this.
|
|
28
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
29
29
|
const firstTouch = activePointers[0];
|
|
30
30
|
if (!firstTouch) {
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
33
|
if (activePointers.length === 1) {
|
|
34
|
-
if (this.
|
|
35
|
-
const clientX = Math.round(firstTouch.clientX - this.
|
|
36
|
-
const clientY = Math.round(firstTouch.clientY - this.
|
|
37
|
-
this.
|
|
38
|
-
const centerX = this.
|
|
39
|
-
const centerY = this.
|
|
40
|
-
const cursorX = (clientX - this.
|
|
41
|
-
const cursorY = (clientY - this.
|
|
42
|
-
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this.
|
|
43
|
-
clearTimeout(this.
|
|
34
|
+
if (this._core.store.state.selectionGroup && this._core.store.state.isRotationHandleSelected) {
|
|
35
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
36
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
37
|
+
this._core.store.setState('isRotating', true);
|
|
38
|
+
const centerX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
39
|
+
const centerY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
40
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
41
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
42
|
+
this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._core.store.state.selectionGroup.rotation;
|
|
43
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
handlePointerMove(event) {
|
|
49
49
|
if (event.pointerType === 'mouse') {
|
|
50
|
-
if (this.
|
|
51
|
-
const clientX = event.clientX - this.
|
|
52
|
-
const clientY = event.clientY - this.
|
|
53
|
-
const groupCenterX = this.
|
|
54
|
-
const groupCenterY = this.
|
|
55
|
-
const cursorX = (clientX - this.
|
|
56
|
-
const cursorY = (clientY - this.
|
|
50
|
+
if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {
|
|
51
|
+
const clientX = event.clientX - this._core.store.offsetX;
|
|
52
|
+
const clientY = event.clientY - this._core.store.offsetY;
|
|
53
|
+
const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
54
|
+
const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
55
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
56
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
57
57
|
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
58
58
|
this.rotation = currentRotation - this.initialRotation;
|
|
59
|
-
this.
|
|
60
|
-
this._store.rerender();
|
|
59
|
+
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
61
60
|
}
|
|
62
61
|
}
|
|
63
62
|
if (event.pointerType === 'touch') {
|
|
64
|
-
const activePointers = Array.from(this.
|
|
63
|
+
const activePointers = Array.from(this._core.store.state.pointers.values());
|
|
65
64
|
const firstTouch = activePointers[0];
|
|
66
65
|
if (!firstTouch) {
|
|
67
66
|
return;
|
|
68
67
|
}
|
|
69
|
-
if (this.
|
|
70
|
-
const clientX = Math.round(firstTouch.clientX - this.
|
|
71
|
-
const clientY = Math.round(firstTouch.clientY - this.
|
|
72
|
-
const groupCenterX = this.
|
|
73
|
-
const groupCenterY = this.
|
|
74
|
-
const cursorX = (clientX - this.
|
|
75
|
-
const cursorY = (clientY - this.
|
|
68
|
+
if (this._core.store.state.isRotating && this._core.store.state.selectionGroup) {
|
|
69
|
+
const clientX = Math.round(firstTouch.clientX - this._core.store.offsetX);
|
|
70
|
+
const clientY = Math.round(firstTouch.clientY - this._core.store.offsetY);
|
|
71
|
+
const groupCenterX = this._core.store.state.selectionGroup.translateX + this._core.store.state.selectionGroup.width / 2 / this._core.store.state.scale;
|
|
72
|
+
const groupCenterY = this._core.store.state.selectionGroup.translateY + this._core.store.state.selectionGroup.height / 2 / this._core.store.state.scale;
|
|
73
|
+
const cursorX = (clientX - this._core.store.state.translateX) / this._core.store.state.scale;
|
|
74
|
+
const cursorY = (clientY - this._core.store.state.translateY) / this._core.store.state.scale;
|
|
76
75
|
const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);
|
|
77
76
|
this.rotation = currentRotation - this.initialRotation;
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
-
clearTimeout(this._store.state.longTouchTimeout);
|
|
77
|
+
this._core.store.state.selectionGroup.rotate(this.rotation);
|
|
78
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
handlePointerUp(event) {
|
|
85
83
|
if (event.pointerType === 'mouse') {
|
|
86
|
-
if (this.
|
|
87
|
-
const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this.
|
|
88
|
-
const updateObjectsCommand = this.
|
|
89
|
-
return new UpdateObjectCommand(this.
|
|
84
|
+
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, {
|
|
90
88
|
rotation: object.rotation,
|
|
91
89
|
translateX: object.translateX,
|
|
92
90
|
translateY: object.translateY,
|
|
93
91
|
});
|
|
94
92
|
});
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
93
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
94
|
+
this._core.store.setState('isRotating', false);
|
|
97
95
|
this.initialRotation = 0;
|
|
98
96
|
this.rotation = 0;
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
if (event.pointerType === 'touch') {
|
|
102
|
-
if (this.
|
|
103
|
-
const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this.
|
|
104
|
-
const updateObjectsCommand = this.
|
|
105
|
-
return new UpdateObjectCommand(this.
|
|
100
|
+
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, {
|
|
106
104
|
rotation: object.rotation,
|
|
107
105
|
});
|
|
108
106
|
});
|
|
109
|
-
this.
|
|
110
|
-
this.
|
|
107
|
+
this._core.history.executeCommand(new BatchCommand(this._core, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));
|
|
108
|
+
this._core.store.setState('isRotating', false);
|
|
111
109
|
this.initialRotation = 0;
|
|
112
110
|
this.rotation = 0;
|
|
113
|
-
clearTimeout(this.
|
|
111
|
+
clearTimeout(this._core.store.state.longTouchTimeout);
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotation.handler.js","sourceRoot":"","sources":["../../../src/classes/handlers/rotation.handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;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from '../store.class';\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\n\r\nexport class KritzelRotationHandler extends KritzelBaseHandler {\r\n initialRotation: number = 0;\r\n\r\n rotation: number = 0;\r\n\r\n constructor(store: KritzelStore) {\r\n super(store);\r\n }\r\n\r\n handlePointerDown(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (KritzelEventHelper.isLeftClick(event)) {\r\n if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n this._store.state.isRotating = true;\r\n\r\n const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;\r\n }\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (activePointers.length === 1) {\r\n if (this._store.state.selectionGroup && this._store.state.isRotationHandleSelected) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n this._store.state.isRotating = true;\r\n\r\n const centerX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const centerY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n this.initialRotation = Math.atan2(centerY - cursorY, centerX - cursorX) - this._store.state.selectionGroup.rotation;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n }\r\n\r\n handlePointerMove(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isRotating && this._store.state.selectionGroup) {\r\n const clientX = event.clientX - this._store.offsetX;\r\n const clientY = event.clientY - this._store.offsetY;\r\n\r\n const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._store.state.selectionGroup.rotate(this.rotation);\r\n\r\n this._store.rerender();\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n const activePointers = Array.from(this._store.state.pointers.values());\r\n const firstTouch = activePointers[0];\r\n\r\n if (!firstTouch) {\r\n return;\r\n }\r\n\r\n if (this._store.state.isRotating && this._store.state.selectionGroup) {\r\n const clientX = Math.round(firstTouch.clientX - this._store.offsetX);\r\n const clientY = Math.round(firstTouch.clientY - this._store.offsetY);\r\n\r\n const groupCenterX = this._store.state.selectionGroup.translateX + this._store.state.selectionGroup.width / 2 / this._store.state.scale;\r\n const groupCenterY = this._store.state.selectionGroup.translateY + this._store.state.selectionGroup.height / 2 / this._store.state.scale;\r\n\r\n const cursorX = (clientX - this._store.state.translateX) / this._store.state.scale;\r\n const cursorY = (clientY - this._store.state.translateY) / this._store.state.scale;\r\n\r\n const currentRotation = Math.atan2(groupCenterY - cursorY, groupCenterX - cursorX);\r\n\r\n this.rotation = currentRotation - this.initialRotation;\r\n\r\n this._store.state.selectionGroup.rotate(this.rotation);\r\n\r\n this._store.rerender();\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n\r\n handlePointerUp(event: PointerEvent): void {\r\n if (event.pointerType === 'mouse') {\r\n if (this._store.state.isRotating) {\r\n const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._store, this, this.rotation);\r\n const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._store, 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._store.history.executeCommand(new BatchCommand(this._store, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));\r\n\r\n this._store.state.isRotating = false;\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n }\r\n }\r\n\r\n if (event.pointerType === 'touch') {\r\n if (this._store.state.isRotating) {\r\n const rotateSelectionGroupCommand = new RotateSelectionGroupCommand(this._store, this, this.rotation);\r\n const updateObjectsCommand = this._store.state.selectionGroup.objects.map(object => {\r\n return new UpdateObjectCommand(this._store, this, object, {\r\n rotation: object.rotation,\r\n });\r\n });\r\n\r\n this._store.history.executeCommand(new BatchCommand(this._store, this, [rotateSelectionGroupCommand, ...updateObjectsCommand]));\r\n\r\n this._store.state.isRotating = false;\r\n\r\n this.initialRotation = 0;\r\n this.rotation = 0;\r\n\r\n clearTimeout(this._store.state.longTouchTimeout);\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
|
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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,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACrG,MAAM,oBAAoB,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACtF,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE;wBACvD,QAAQ,EAAE,MAAM,CAAC,QAAQ;qBAC1B,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,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"]}
|