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.

57 lines 3.1 kB
import { InputHandlerType } from "./InputHandlerType"; import { InputManager } from "./../../Input/InputManager/InputManager"; import { Viewer } from "./../../Viewer"; import { ViewerCoordinatesConvertor } from "./../../Input/InputManager/ViewerCoordinatesConvertor"; import { HtmlInputManagerAdapter } from "./../../Input/InputManager/HtmlInputManagerAdapter"; import { InputHandlerFactory } from "./InputHandlerFactory"; import { isCompletableInputHandler } from "./../../Input/InputManager/ICompletableInputHandler"; var InputHandlerManager = /** @class */ (function () { function InputHandlerManager(_viewer, element, keyInputElement) { var _this = this; this._viewer = _viewer; this._onInputHandlerComplete = function (result) { var _a; _this._viewer.eventManager.createInputHandlerFinishedEvent.notify(result); if (((_a = _this._setInputHandlerOptions) === null || _a === void 0 ? void 0 : _a.resetToDefaultInput) == null || _this._setInputHandlerOptions.resetToDefaultInput) _this.setInputHandlerType(InputHandlerType.Default); }; this._inputManager = new InputManager(new ViewerCoordinatesConvertor(this._viewer)); this._htmlInputMangerAdapter = new HtmlInputManagerAdapter(element, keyInputElement, this._inputManager, Viewer.preventKeyHandleClass, Viewer.preventClickHandleClass); this._factory = new InputHandlerFactory(this._viewer, this._inputManager); } Object.defineProperty(InputHandlerManager.prototype, "inputManager", { get: function () { return this._inputManager; }, enumerable: true, configurable: true }); Object.defineProperty(InputHandlerManager.prototype, "isDefault", { get: function () { return this._currentInputHandlerType === InputHandlerType.Default; }, enumerable: true, configurable: true }); InputHandlerManager.prototype.setInputHandlerType = function (type, args, options) { var _a; if (isCompletableInputHandler(this._currentInputHandler)) this._currentInputHandler.removeOnCompleted(this._onInputHandlerComplete); this._setInputHandlerOptions = options; this._currentInputHandlerType = type; (_a = this._currentInputHandler) === null || _a === void 0 ? void 0 : _a.dispose(); this._currentInputHandler = this._factory.create(type, args); if (isCompletableInputHandler(this._currentInputHandler)) this._currentInputHandler.addOnCompleted(this._onInputHandlerComplete); this._viewer.canvas.updateButtonGroups(); }; InputHandlerManager.prototype.dispose = function () { var _a; this._inputManager.dispose(); this._htmlInputMangerAdapter.dispose(); (_a = this._currentInputHandler) === null || _a === void 0 ? void 0 : _a.dispose(); }; return InputHandlerManager; }()); export { InputHandlerManager }; //# sourceMappingURL=InputHandlerManager.js.map