/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ import { Injectable, Inject } from '@angular/core'; import { OverlayContainer } from './overlay-container'; import { DOCUMENT } from '@angular/common'; import { Platform } from '@angular/cdk/platform'; import * as i0 from "@angular/core"; import * as i1 from "@angular/common"; import * as i2 from "@angular/cdk/platform"; /** * Alternative to OverlayContainer that supports correct displaying of overlay elements in * Fullscreen mode * https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen * * Should be provided in the root component. */ export class FullscreenOverlayContainer extends OverlayContainer { constructor(_document, platform) { super(_document, platform); } ngOnDestroy() { super.ngOnDestroy(); if (this._fullScreenEventName && this._fullScreenListener) { this._document.removeEventListener(this._fullScreenEventName, this._fullScreenListener); } } _createContainer() { super._createContainer(); this._adjustParentForFullscreenChange(); this._addFullscreenChangeListener(() => this._adjustParentForFullscreenChange()); } _adjustParentForFullscreenChange() { if (!this._containerElement) { return; } const fullscreenElement = this.getFullscreenElement(); const parent = fullscreenElement || this._document.body; parent.appendChild(this._containerElement); } _addFullscreenChangeListener(fn) { const eventName = this._getEventName(); if (eventName) { if (this._fullScreenListener) { this._document.removeEventListener(eventName, this._fullScreenListener); } this._document.addEventListener(eventName, fn); this._fullScreenListener = fn; } } _getEventName() { if (!this._fullScreenEventName) { const _document = this._document; if (_document.fullscreenEnabled) { this._fullScreenEventName = 'fullscreenchange'; } else if (_document.webkitFullscreenEnabled) { this._fullScreenEventName = 'webkitfullscreenchange'; } else if (_document.mozFullScreenEnabled) { this._fullScreenEventName = 'mozfullscreenchange'; } else if (_document.msFullscreenEnabled) { this._fullScreenEventName = 'MSFullscreenChange'; } } return this._fullScreenEventName; } /** * When the page is put into fullscreen mode, a specific element is specified. * Only that element and its children are visible when in fullscreen mode. */ getFullscreenElement() { const _document = this._document; return _document.fullscreenElement || _document.webkitFullscreenElement || _document.mozFullScreenElement || _document.msFullscreenElement || null; } } FullscreenOverlayContainer.ɵprov = i0.ɵɵdefineInjectable({ factory: function FullscreenOverlayContainer_Factory() { return new FullscreenOverlayContainer(i0.ɵɵinject(i1.DOCUMENT), i0.ɵɵinject(i2.Platform)); }, token: FullscreenOverlayContainer, providedIn: "root" }); FullscreenOverlayContainer.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; FullscreenOverlayContainer.ctorParameters = () => [ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }, { type: Platform } ]; //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVsbHNjcmVlbi1vdmVybGF5LWNvbnRhaW5lci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvb3ZlcmxheS9mdWxsc2NyZWVuLW92ZXJsYXktY29udGFpbmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxVQUFVLEVBQUUsTUFBTSxFQUFZLE1BQU0sZUFBZSxDQUFDO0FBQzVELE9BQU8sRUFBQyxnQkFBZ0IsRUFBQyxNQUFNLHFCQUFxQixDQUFDO0FBQ3JELE9BQU8sRUFBQyxRQUFRLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QyxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7Ozs7QUFHL0M7Ozs7OztHQU1HO0FBRUgsTUFBTSxPQUFPLDBCQUEyQixTQUFRLGdCQUFnQjtJQUk5RCxZQUE4QixTQUFjLEVBQUUsUUFBa0I7UUFDOUQsS0FBSyxDQUFDLFNBQVMsRUFBRSxRQUFRLENBQUMsQ0FBQztJQUM3QixDQUFDO0lBRVEsV0FBVztRQUNsQixLQUFLLENBQUMsV0FBVyxFQUFFLENBQUM7UUFFcEIsSUFBSSxJQUFJLENBQUMsb0JBQW9CLElBQUksSUFBSSxDQUFDLG1CQU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