UNPKG

@aurigma/design-atoms

Version:

Design Atoms is a part of Customer's Canvas SDK which allows for manipulating individual design elements through your code.

34 lines 1.64 kB
import { Matrix, normalizeAngle } from "@aurigma/design-atoms-model/Math"; import { BaseItemsCommand } from "../BaseItemsCommand"; import { HistoryUpdateMode } from "../../ModelUpdateCommand"; import { NotImplementedException, ArgumentException } from "@aurigma/design-atoms-model/Exception"; import { ItemsCommand } from "@aurigma/design-atoms-interfaces"; export class RotateItemsCommand extends BaseItemsCommand { constructor(productHandler, historyArgs, args, _commandManager) { super(productHandler, historyArgs, args); this._commandManager = _commandManager; } async _executeCommandBody() { let { angle, origin, finished } = this._args; const items = this._getTargetItems(this._args.items, this._args.query, this._args.queryOptions); if (angle == null || items == null || origin == null) throw new ArgumentException("RotateItemsCommand: angle, items and origin cannot be null"); angle = normalizeAngle(angle); const matrix = new Matrix().rotateAt(angle, origin.x, origin.y); let itemsTransformArgs = { items: items, matrix: matrix, finished: finished, newAngle: angle }; const historyMode = finished ? HistoryUpdateMode.ForceUpdate : HistoryUpdateMode.NotUpdate; await this._commandManager.execute(ItemsCommand.transformItems, itemsTransformArgs, historyMode); } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=RotateItemsCommand.js.map