var MenuControl = /** @class */ (function () {
    function MenuControl(viewer) {
        this._defaultMenus = [];
        this._customMenus = [];
        this._isMenuVisable = false;
        this._offset = { x: 0, y: 0 };
        this._menuDOM = document.createElement('div');
        this._viewer = viewer;
        var _a = this, dom = _a._menuDOM, defMenus = _a._defaultMenus;
        dom.style.minWidth = '100px';
        dom.style.minHeight = '200px';
        dom.style.background = 'white';
        dom.style.position = 'fixed';
        defMenus.push({
            title: '右键菜单_1',
            callback: function (evt) {
                // console.log('右键菜单', evt);
            }
        });
        defMenus.push({
            title: '右键菜单_2',
            callback: function (evt) {
                alert(2);
            }
        });
    }
    MenuControl.prototype.renderMenuItems = function () {
        var _a = this, defMenus = _a._defaultMenus, dom = _a._menuDOM;
        var child = dom.lastElementChild;
        while (child) {
            dom.removeChild(child);
            child = dom.lastElementChild;
        }
        for (var i = 0; i < defMenus.length; i++) {
            var domItem = document.createElement('div');
            var menuItem = defMenus[i];
            domItem.innerHTML = menuItem.title;
            dom.appendChild(domItem);
        }
    };
    MenuControl.prototype.open = function (evt) {
        var _a = this, dom = _a._menuDOM, viewer = _a._viewer;
        var x = evt.pageX, y = evt.pageY;
        this._offset = { x: x, y: y };
        // console.log('打开菜单', this._offset);
        dom.style.left = x + "px";
        dom.style.top = y + "px";
        this.renderMenuItems();
        viewer.container.appendChild(dom);
    };
    MenuControl.prototype.close = function () {
        var _a = this, dom = _a._menuDOM, viewer = _a._viewer;
        // console.log('关闭菜单');
        dom.remove();
    };
    return MenuControl;
}());
export default MenuControl;
