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.

43 lines 1.98 kB
import { Matrix, EqualsOfFloatNumbers } 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 ResizeItemsCommand extends BaseItemsCommand { constructor(productHandler, historyArgs, args, _commandManager) { super(productHandler, historyArgs, args); this._commandManager = _commandManager; } async _executeCommandBody() { let { origin, scaleX, scaleY, finished, angle } = this._args; const items = this._getTargetItems(this._args.items, this._args.query, this._args.queryOptions); if (origin == null || items == null || scaleX == null || scaleY == null) throw new ArgumentException("ResizeItemsCommand: origin, scale and items cannot be null"); let matrix; if (angle != null && !EqualsOfFloatNumbers(angle, 0)) { matrix = new Matrix() .translate(origin.x, origin.y) .rotate(angle) .scale(scaleX, scaleY) .rotate(-angle) .translate(-origin.x, -origin.y); } else { matrix = new Matrix().scaleRelativeToPoint(scaleX, scaleY, origin); } let itemsTransformArgs = { items: items, matrix: matrix, finished: finished }; const historyMode = finished ? HistoryUpdateMode.ForceUpdate : HistoryUpdateMode.NotUpdate; await this._commandManager.execute(ItemsCommand.transformItems, itemsTransformArgs, historyMode); } redo() { throw new NotImplementedException(); } undo() { throw new NotImplementedException(); } } //# sourceMappingURL=ResizeItemsCommand.js.map