UNPKG

dockview

Version:

Zero dependency layout manager supporting tabs, grids and splitviews with ReactJS support

74 lines 3.21 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HostedContainer = void 0; var dom_1 = require("./dom"); var events_1 = require("./events"); var HostedContainer = /** @class */ (function () { function HostedContainer(options) { var _this = this; this.options = options; this._onDidFocus = new events_1.Emitter(); this.onDidFocus = this._onDidFocus.event; this._onDidBlur = new events_1.Emitter(); this.onDidBlur = this._onDidBlur.event; if (!options.parent) { options.parent = document.getElementById('app'); options.parent.style.position = 'relative'; } this._element = document.createElement('div'); this._element.style.visibility = 'hidden'; this._element.style.overflow = 'hidden'; // this._element.style.pointerEvents = 'none'; this._element.id = "webview-".concat(options.id); this._element.tabIndex = -1; var _a = (0, dom_1.trackFocus)(this._element), onDidFocus = _a.onDidFocus, onDidBlur = _a.onDidBlur; onDidFocus(function () { return _this._onDidFocus.fire(); }); onDidBlur(function () { return _this._onDidBlur.fire(); }); /** * When dragging somebody */ window.addEventListener('dragstart', function (ev) { _this.element.style.pointerEvents = 'none'; }); window.addEventListener('dragend', function (ev) { _this.element.style.pointerEvents = ''; }); window.addEventListener('mousemove', function (ev) { if (ev.buttons === 0) { _this.element.style.pointerEvents = ''; } }); options.parent.appendChild(this._element); } Object.defineProperty(HostedContainer.prototype, "element", { get: function () { return this._element; }, enumerable: false, configurable: true }); HostedContainer.prototype.hide = function () { this._element.style.visibility = 'hidden'; }; HostedContainer.prototype.show = function () { this._element.style.visibility = 'visible'; }; HostedContainer.prototype.layout = function (element, dimension) { if (!this.element || !this.element.parentElement) { return; } var frameRect = element.getBoundingClientRect(); var containerRect = this.element.parentElement.getBoundingClientRect(); this.element.style.position = 'absolute'; this.element.style.top = "".concat(frameRect.top - containerRect.top, "px"); this.element.style.left = "".concat(frameRect.left - containerRect.left, "px"); this.element.style.width = "".concat(dimension ? dimension.width : frameRect.width, "px"); this.element.style.height = "".concat(dimension ? dimension.height : frameRect.height, "px"); }; HostedContainer.prototype.dispose = function () { this._element.remove(); }; return HostedContainer; }()); exports.HostedContainer = HostedContainer; //# sourceMappingURL=hostedContainer.js.map