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.

42 lines 1.82 kB
import { InputState } from "../../InputManager/IInputManager"; import { EventObject } from "@aurigma/design-atoms-model/EventObject"; import { Rubberband } from "./../../../Rubberband"; export class RubberbandHandler { constructor() { this._isActive = false; this._rubberbandChanged = new EventObject(); this.draw = (ctx, renderer, offset) => { if (this._rubberband != null) renderer.drawRubberband(ctx, this._rubberband, offset); }; this._clearRubberband = () => { const result = this._rubberband; this._rubberband = null; this._isActive = false; this._rubberbandChanged.notify(); return result; }; this._updateRubberband = (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; }; } get isActive() { return this._isActive; } updateRubberband(point, startPoint, state) { this._isActive = state !== InputState.Finished; return this._isActive ? this._updateRubberband(point, startPoint) : this._clearRubberband(); } addOnRubberbandChanged(handler) { this._rubberbandChanged.add(handler); } removeOnRubberbandChanged(handler) { this._rubberbandChanged.remove(handler); } } //# sourceMappingURL=RubberbandHandler.js.map