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.

49 lines 2.25 kB
import { InputState } from "../../InputManager/IInputManager"; import { EventObject } from "@aurigma/design-atoms-model/EventObject"; import { Rubberband } from "./../../../Rubberband"; var RubberbandHandler = /** @class */ (function () { function RubberbandHandler() { var _this = this; this._isActive = false; this._rubberbandChanged = new EventObject(); this.draw = function (ctx, renderer, offset) { if (_this._rubberband != null) renderer.drawRubberband(ctx, _this._rubberband, offset); }; this._clearRubberband = function () { var result = _this._rubberband; _this._rubberband = null; _this._isActive = false; _this._rubberbandChanged.notify(); return result; }; this._updateRubberband = function (point, startPoint) { var _a, _b; _this._rubberband = new Rubberband((_a = startPoint === null || startPoint === void 0 ? void 0 : startPoint.x) !== null && _a !== void 0 ? _a : _this._rubberband.left, (_b = startPoint === null || startPoint === void 0 ? void 0 : startPoint.y) !== null && _b !== void 0 ? _b : _this._rubberband.top, point.x, point.y); _this._rubberbandChanged.notify(); return _this._rubberband; }; } Object.defineProperty(RubberbandHandler.prototype, "isActive", { get: function () { return this._isActive; }, enumerable: true, configurable: true }); RubberbandHandler.prototype.updateRubberband = function (point, startPoint, state) { this._isActive = state !== InputState.Finished; return this._isActive ? this._updateRubberband(point, startPoint) : this._clearRubberband(); }; RubberbandHandler.prototype.addOnRubberbandChanged = function (handler) { this._rubberbandChanged.add(handler); }; RubberbandHandler.prototype.removeOnRubberbandChanged = function (handler) { this._rubberbandChanged.remove(handler); }; return RubberbandHandler; }()); export { RubberbandHandler }; //# sourceMappingURL=RubberbandHandler.js.map