angular-duo-pane
Version:
A library for Angular projects to easily add a two pane view for desktops, foldables and dual screen devices.
788 lines (753 loc) • 36.5 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core')) :
typeof define === 'function' && define.amd ? define('angular-duo-pane', ['exports', '@angular/core'], factory) :
(global = global || self, factory(global['angular-duo-pane'] = {}, global.ng.core));
}(this, (function (exports, core) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var __assign = function() {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __decorate(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
}
function __param(paramIndex, decorator) {
return function (target, key) { decorator(target, key, paramIndex); }
}
function __metadata(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
}
function __awaiter(thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
function __generator(thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (_) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
}
function __exportStar(m, exports) {
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
}
function __values(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function __read(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m) return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
}
catch (error) { e = { error: error }; }
finally {
try {
if (r && !r.done && (m = i["return"])) m.call(i);
}
finally { if (e) throw e.error; }
}
return ar;
}
function __spread() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read(arguments[i]));
return ar;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function __await(v) {
return this instanceof __await ? (this.v = v, this) : new __await(v);
}
function __asyncGenerator(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
function fulfill(value) { resume("next", value); }
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
}
function __asyncDelegator(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
}
function __asyncValues(o) {
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
}
function __makeTemplateObject(cooked, raw) {
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
return cooked;
};
function __importStar(mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
result.default = mod;
return result;
}
function __importDefault(mod) {
return (mod && mod.__esModule) ? mod : { default: mod };
}
function __classPrivateFieldGet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
}
function __classPrivateFieldSet(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
}
var Segment = /** @class */ (function () {
function Segment(width, height, top, left) {
this.width = width;
this.height = height;
this.top = top;
this.left = left;
}
Object.defineProperty(Segment.prototype, "width", {
get: function () {
return this.Width;
},
set: function (value) {
this.Width = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Segment.prototype, "height", {
get: function () {
return this.Height;
},
set: function (value) {
this.Height = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Segment.prototype, "top", {
get: function () {
return this.Top;
},
set: function (value) {
this.Top = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Segment.prototype, "left", {
get: function () {
return this.Left;
},
set: function (value) {
this.Left = value;
},
enumerable: true,
configurable: true
});
return Segment;
}());
var DuoPaneComponent = /** @class */ (function () {
function DuoPaneComponent(changeDetectorRef) {
this.changeDetectorRef = changeDetectorRef;
this.embeddedViewRef = null;
this.Segment = new Segment(0, 0, 0, 0);
this.ContentTemplateRef = undefined;
}
Object.defineProperty(DuoPaneComponent.prototype, "segment", {
get: function () {
return this.Segment;
},
set: function (value) {
this.Segment = value;
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneComponent.prototype, "contentTemplateRef", {
get: function () {
return this.ContentTemplateRef;
},
set: function (value) {
if (value instanceof core.TemplateRef) {
this.ContentTemplateRef = value;
this.renderView();
}
},
enumerable: true,
configurable: true
});
DuoPaneComponent.prototype.ngAfterViewInit = function () {
this.renderView();
};
DuoPaneComponent.prototype.renderView = function () {
if (this.ContentTemplateRef && this.viewContainerRef) {
if (this.embeddedViewRef) {
this.embeddedViewRef.destroy();
}
this.viewContainerRef.clear();
this.embeddedViewRef = this.viewContainerRef.createEmbeddedView(this.ContentTemplateRef);
this.changeDetectorRef.detectChanges();
}
};
DuoPaneComponent.ctorParameters = function () { return [
{ type: core.ChangeDetectorRef }
]; };
__decorate([
core.ViewChild('viewContainer', { read: core.ViewContainerRef, static: true })
], DuoPaneComponent.prototype, "viewContainerRef", void 0);
__decorate([
core.Input()
], DuoPaneComponent.prototype, "segment", null);
__decorate([
core.Input()
], DuoPaneComponent.prototype, "contentTemplateRef", null);
DuoPaneComponent = __decorate([
core.Component({
selector: 'duo-pane',
template: "<div class=\"dual-screen-view-pane\" [style.left]=\"segment.left + 'px'\" [style.top]=\"segment.top + 'px'\" [style.height]=\"segment.height + 'px'\" [style.width]=\"segment.width + 'px'\">\n <ng-container #viewContainer></ng-container>\n</div>\n",
styles: [".dual-screen-view-pane{position:absolute;overflow:auto}"]
})
], DuoPaneComponent);
return DuoPaneComponent;
}());
var DuoPaneInformationService = /** @class */ (function () {
function DuoPaneInformationService() {
var _this = this;
this.Spanning = 'none';
this.FoldSize = 0;
this.BrowserShellSize = 0;
this.Segments = null;
this.needsDispatch = false;
this.Spanning = sessionStorage.getItem(DuoPaneInformationService_1.ns + "-spanning") || 'none';
this.FoldSize = +sessionStorage.getItem(DuoPaneInformationService_1.ns + "-fold-size") || 0;
this.BrowserShellSize = +sessionStorage.getItem(DuoPaneInformationService_1.ns + "-browser-shell-size") || 0;
this.eventTarget = document.createDocumentFragment();
// Web-based emulator runs this polyfill in an iframe, we need to
// communicate emulator state changes to the site.
// Should only be registered once (in CSS or JS polyfill, not both).
window.addEventListener('message', function (ev) {
if (ev.data.action === 'update') {
Object.assign(_this, ev.data.value);
}
});
window.addEventListener('resize', function () { return _this.debounce(_this.invalidate(), 200); });
}
DuoPaneInformationService_1 = DuoPaneInformationService;
DuoPaneInformationService.prototype.addEventListener = function (type, listener, options) {
this.eventTarget.addEventListener(type, listener, options);
};
DuoPaneInformationService.prototype.removeEventListener = function (type, callback, options) {
this.eventTarget.removeEventListener(type, callback, options);
};
DuoPaneInformationService.prototype.dispatchEvent = function (event) {
if (event.type !== 'change') {
return;
}
var methodName = "on" + event.type;
if (typeof this[methodName] === 'function') {
this[methodName](event);
}
return this.eventTarget.dispatchEvent(event);
};
Object.defineProperty(DuoPaneInformationService.prototype, "foldSize", {
get: function () {
return this.FoldSize;
},
set: function (foldSize) {
sessionStorage.setItem(DuoPaneInformationService_1.ns + "-fold-size", foldSize.toString());
this.FoldSize = foldSize;
this.invalidate();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneInformationService.prototype, "browserShellSize", {
get: function () {
return this.BrowserShellSize;
},
set: function (browserShellSize) {
sessionStorage.setItem(DuoPaneInformationService_1.ns + "-browser-shell-size", browserShellSize.toString());
this.BrowserShellSize = browserShellSize;
this.invalidate();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneInformationService.prototype, "spanning", {
get: function () {
return this.Spanning;
},
set: function (spanning) {
sessionStorage.setItem(DuoPaneInformationService_1.ns + "-spanning", spanning);
this.Spanning = spanning;
this.invalidate();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneInformationService.prototype, "segments", {
set: function (segments) {
this.Segments = segments;
},
enumerable: true,
configurable: true
});
DuoPaneInformationService.prototype.getTwoLargestSegments = function () {
var e_1, _a;
var segments = this.windowSegments;
if (segments.length > 2) {
var twoLargestSegments = [null, null];
var largestSize = 0;
try {
for (var segments_1 = __values(segments), segments_1_1 = segments_1.next(); !segments_1_1.done; segments_1_1 = segments_1.next()) {
var segment = segments_1_1.value;
var segmentSize = segment.height * segment.width;
if (segmentSize >= largestSize) {
largestSize = segmentSize;
twoLargestSegments[0] = twoLargestSegments[1];
twoLargestSegments[1] = segment;
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (segments_1_1 && !segments_1_1.done && (_a = segments_1.return)) _a.call(segments_1);
}
finally { if (e_1) throw e_1.error; }
}
return twoLargestSegments;
}
else {
return segments;
}
};
Object.defineProperty(DuoPaneInformationService.prototype, "windowSegments", {
get: function () {
// TODO: replace with window.getWindowSegments() once it is a web standard
if (this.Segments !== null && this.Segments.length > 0) {
return this.Segments;
}
if (this.spanning === 'none') {
return [
new Segment(window.innerWidth, window.innerHeight, 0, 0)
];
}
if (this.spanning === 'single-fold-horizontal') {
var screenCenter = (window.innerHeight - this.browserShellSize) / 2;
var width = window.innerWidth;
return [
new Segment(width, screenCenter - this.foldSize / 2, 0, 0),
new Segment(width, this.foldSize, screenCenter - this.foldSize / 2, 0),
new Segment(width, window.innerHeight, screenCenter + this.foldSize / 2, 0)
];
}
if (this.spanning === 'single-fold-vertical') {
var width = window.innerWidth / 2 - this.foldSize / 2;
var height = window.innerHeight;
return [
new Segment(width, height, 0, 0),
new Segment(this.foldSize, height, 0, width),
new Segment(width, height, 0, window.innerWidth / 2 + this.foldSize / 2)
];
}
},
enumerable: true,
configurable: true
});
/**
* Returns a function that won't call `fn` if it was invoked at a
* faster interval than `wait`.
*/
DuoPaneInformationService.prototype.debounce = function (fn, wait) {
var timeout;
return function () {
clearTimeout(timeout);
timeout = setTimeout(function () {
fn.apply(this, arguments);
}, wait);
};
};
DuoPaneInformationService.prototype.invalidate = function () {
return __awaiter(this, void 0, void 0, function () {
var _a;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
if (!!this.needsDispatch) return [3 /*break*/, 2];
this.needsDispatch = true;
_a = this;
return [4 /*yield*/, Promise.resolve(false)];
case 1:
_a.needsDispatch = _b.sent();
this.dispatchEvent(new Event('change'));
_b.label = 2;
case 2: return [2 /*return*/];
}
});
});
};
var DuoPaneInformationService_1;
DuoPaneInformationService.ns = '__foldables__';
DuoPaneInformationService.ɵprov = core["ɵɵdefineInjectable"]({ factory: function DuoPaneInformationService_Factory() { return new DuoPaneInformationService(); }, token: DuoPaneInformationService, providedIn: "root" });
DuoPaneInformationService = DuoPaneInformationService_1 = __decorate([
core.Injectable({
providedIn: 'root'
})
], DuoPaneInformationService);
return DuoPaneInformationService;
}());
var DuoPaneDirective = /** @class */ (function () {
function DuoPaneDirective(componentfactoryResolver, templateRef, viewContainer, dualScreenInformationService) {
var _this = this;
this.componentfactoryResolver = componentfactoryResolver;
this.templateRef = templateRef;
this.viewContainer = viewContainer;
this.dualScreenInformationService = dualScreenInformationService;
this.secondaryPaneTemplateRef = null;
this.EnsureSecondaryPaneVisible = false;
/* Variables set to control two pane if only one window segment is available-*/
this.TwoPaneMinWidthSingleSegment = 0;
this.TwoPaneMinHeightSingleSegment = 0;
this.TwoPaneSpanningModeSingleSegment = 'none';
this.PrimaryPanePercentageSingleSegment = 50;
this.paneFactory = this.componentfactoryResolver.resolveComponentFactory(DuoPaneComponent);
this.primaryPaneRef = null;
this.secondaryPaneRef = null;
this.secondaryPaneVisibilityHandler = new core.EventEmitter();
this.secondaryPaneVisible = undefined;
dualScreenInformationService.addEventListener('change', function () {
_this.updateView();
});
this.updateView();
}
Object.defineProperty(DuoPaneDirective.prototype, "primaryPanePercentageSingleSegment", {
get: function () {
return this.PrimaryPanePercentageSingleSegment;
},
set: function (value) {
if (typeof value === 'string') {
var fractionValue = Number(value);
if (!isNaN(fractionValue) && fractionValue >= 0 && fractionValue <= 100) {
this.PrimaryPanePercentageSingleSegment = fractionValue;
this.updateView();
}
}
else if (typeof value === 'number') {
if (value >= 0 && value <= 100) {
this.PrimaryPanePercentageSingleSegment = value;
this.updateView();
}
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneDirective.prototype, "secondaryPane", {
set: function (secondaryPane) {
this.secondaryPaneTemplateRef = secondaryPane;
this.destroySecondaryPaneRef();
this.updateView();
},
enumerable: true,
configurable: true
});
DuoPaneDirective.prototype.destroySecondaryPaneRef = function () {
if (this.secondaryPaneRef) {
var secondaryPaneIndex = this.viewContainer.indexOf(this.secondaryPaneRef.hostView);
if (secondaryPaneIndex >= 0) {
this.viewContainer.remove(secondaryPaneIndex);
}
this.secondaryPaneRef.destroy();
this.secondaryPaneRef = null;
}
};
DuoPaneDirective.prototype.destroyPrimaryPaneRef = function () {
if (this.primaryPaneRef) {
var primaryPaneIndex = this.viewContainer.indexOf(this.primaryPaneRef.hostView);
if (primaryPaneIndex >= 0) {
this.viewContainer.remove(primaryPaneIndex);
}
this.primaryPaneRef.destroy();
this.primaryPaneRef = null;
}
};
Object.defineProperty(DuoPaneDirective.prototype, "ensureSecondaryPaneVisible", {
set: function (value) {
this.EnsureSecondaryPaneVisible = value;
this.updateView();
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneDirective.prototype, "twoPaneMinWidthSingleSegment", {
set: function (minWidth) {
if (typeof minWidth === 'string') {
var minWidthValue = Number(minWidth);
if (minWidthValue >= 0 && !isNaN(minWidthValue)) {
this.TwoPaneMinWidthSingleSegment = minWidthValue;
this.updateView();
}
}
else if (typeof minWidth === 'number' && minWidth >= 0) {
this.TwoPaneMinWidthSingleSegment = minWidth;
this.updateView();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneDirective.prototype, "twoPaneMinHeightSingleSegment", {
set: function (minHeight) {
if (typeof minHeight === 'string') {
var minHeightValue = Number(minHeight);
if (minHeightValue >= 0 && !isNaN(minHeightValue)) {
this.TwoPaneMinHeightSingleSegment = minHeightValue;
this.updateView();
}
}
else if (typeof minHeight === 'number' && minHeight >= 0) {
this.TwoPaneMinHeightSingleSegment = minHeight;
this.updateView();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(DuoPaneDirective.prototype, "twoPaneSpanningModeSingleSegment", {
set: function (spanningMode) {
if (spanningMode) {
this.TwoPaneSpanningModeSingleSegment = spanningMode;
this.updateView();
}
},
enumerable: true,
configurable: true
});
DuoPaneDirective.prototype.emitSecondaryPaneVisibility = function (visible) {
if (this.secondaryPaneVisible === undefined || this.secondaryPaneVisible === null || visible !== this.secondaryPaneVisible) {
this.secondaryPaneVisible = visible;
this.secondaryPaneVisibilityHandler.emit(visible);
}
};
DuoPaneDirective.prototype.updateView = function () {
/*this.viewContainer.createEmbeddedView(this.templateRef);
if(this.secondaryPaneTemplateRef != null) {
this.viewContainer.createEmbeddedView(this.secondaryPaneTemplateRef);
}*/
var windowSegements = this.dualScreenInformationService.windowSegments;
if (windowSegements.length > 0) {
if (windowSegements.length > 1) {
this.renderDualPanes(this.dualScreenInformationService.getTwoLargestSegments());
}
else if (windowSegements[0].height >= this.TwoPaneMinHeightSingleSegment
&& windowSegements[0].width >= this.TwoPaneMinWidthSingleSegment
&& this.TwoPaneSpanningModeSingleSegment !== 'none') {
this.renderBothPanes(windowSegements[0]);
}
else {
if (this.EnsureSecondaryPaneVisible) {
this.destroyPrimaryPaneRef();
this.renderSecondaryPane(windowSegements[0]);
}
else {
this.destroySecondaryPaneRef();
this.renderPrimaryPane(windowSegements[0]);
this.emitSecondaryPaneVisibility(false);
}
}
}
};
DuoPaneDirective.prototype.renderBothPanes = function (windowSegment) {
var primarySegment;
var secondarySegment;
if (this.TwoPaneSpanningModeSingleSegment === 'single-fold-horizontal') {
var fraction = this.PrimaryPanePercentageSingleSegment / 100;
primarySegment = new Segment(windowSegment.width, windowSegment.height * fraction, 0, 0);
secondarySegment = new Segment(windowSegment.width, windowSegment.height * (1 - fraction), windowSegment.height * fraction, 0);
}
else if (this.TwoPaneSpanningModeSingleSegment === 'single-fold-vertical') {
var fraction = this.PrimaryPanePercentageSingleSegment / 100;
primarySegment = new Segment(windowSegment.width * fraction, windowSegment.height, 0, 0);
secondarySegment = new Segment(windowSegment.width * (1 - fraction), windowSegment.height, 0, windowSegment.width * fraction);
}
else {
return;
}
this.renderDualPanes([primarySegment, secondarySegment]);
};
DuoPaneDirective.prototype.renderDualPanes = function (windowSegments) {
if (windowSegments.length > 0) {
this.renderPrimaryPane(windowSegments[0]);
}
if (windowSegments.length > 1) {
this.renderSecondaryPane(windowSegments[1]);
}
};
DuoPaneDirective.prototype.renderPrimaryPane = function (segment) {
// const paneFactory = this.componentfactoryResolver.resolveComponentFactory(PrimaryPaneComponent);
if (!this.primaryPaneRef) {
this.primaryPaneRef = this.viewContainer.createComponent(this.paneFactory);
}
this.primaryPaneRef.instance.segment = segment;
this.primaryPaneRef.instance.contentTemplateRef = this.templateRef;
};
DuoPaneDirective.prototype.renderSecondaryPane = function (segment) {
if (this.secondaryPaneTemplateRef !== null && this.secondaryPaneTemplateRef !== undefined) {
// const paneFactory = this.componentfactoryResolver.resolveComponentFactory(PrimaryPaneComponent);
if (!this.secondaryPaneRef) {
this.secondaryPaneRef = this.viewContainer.createComponent(this.paneFactory);
}
this.secondaryPaneRef.instance.segment = segment;
this.secondaryPaneRef.instance.contentTemplateRef = this.secondaryPaneTemplateRef;
this.emitSecondaryPaneVisibility(true);
}
};
DuoPaneDirective.ctorParameters = function () { return [
{ type: core.ComponentFactoryResolver },
{ type: core.TemplateRef },
{ type: core.ViewContainerRef },
{ type: DuoPaneInformationService }
]; };
__decorate([
core.Input()
], DuoPaneDirective.prototype, "primaryPanePercentageSingleSegment", null);
__decorate([
core.Output()
], DuoPaneDirective.prototype, "secondaryPaneVisibilityHandler", void 0);
__decorate([
core.Input()
], DuoPaneDirective.prototype, "secondaryPane", null);
__decorate([
core.Input()
], DuoPaneDirective.prototype, "ensureSecondaryPaneVisible", null);
__decorate([
core.Input()
], DuoPaneDirective.prototype, "twoPaneMinWidthSingleSegment", null);
__decorate([
core.Input()
], DuoPaneDirective.prototype, "twoPaneMinHeightSingleSegment", null);
__decorate([
core.Input()
], DuoPaneDirective.prototype, "twoPaneSpanningModeSingleSegment", null);
DuoPaneDirective = __decorate([
core.Directive({
selector: '[duoPane]'
})
], DuoPaneDirective);
return DuoPaneDirective;
}());
var AngularDuoPaneModule = /** @class */ (function () {
function AngularDuoPaneModule() {
}
AngularDuoPaneModule = __decorate([
core.NgModule({
declarations: [DuoPaneComponent, DuoPaneDirective],
imports: [],
exports: [DuoPaneDirective, DuoPaneComponent]
})
], AngularDuoPaneModule);
return AngularDuoPaneModule;
}());
exports.AngularDuoPaneModule = AngularDuoPaneModule;
exports.DuoPaneDirective = DuoPaneDirective;
exports.Segment = Segment;
exports.ɵa = DuoPaneComponent;
exports.ɵb = DuoPaneInformationService;
Object.defineProperty(exports, '__esModule', { value: true });
})));
//# sourceMappingURL=angular-duo-pane.umd.js.map