/** * @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/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); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: FullscreenOverlayContainer, deps: [{ token: DOCUMENT }, { token: i1.Platform }], target: i0.ɵɵFactoryTarget.Injectable }); } static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: FullscreenOverlayContainer, providedIn: 'root' }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.1.1", ngImport: i0, type: FullscreenOverlayContainer, decorators: [{ type: Injectable, args: [{ providedIn: 'root' }] }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT] }] }, { type: i1.Platform }]; } }); //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZnVsbHNjcmVlbi1vdmVybGF5LWNvbnRhaW5lci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uL3NyYy9jZGsvb3ZlcmxheS9mdWxsc2NyZWVuLW92ZXJsYXktY29udGFpbmVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRztBQUVILE9BQU8sRUFBQyxVQUFVLEVBQUUsTUFBTSxFQUFZLE1BQU0sZUFBZSxDQUFDO0FBQzVELE9BQU8sRUFBQyxnQkFBZ0IsRUFBQyxNQUFNLHFCQUFxQixDQUFDO0FBQ3JELE9BQU8sRUFBQyxRQUFRLEVBQUMsTUFBTSxpQkFBaUIsQ0FBQztBQUN6QyxPQUFPLEVBQUMsUUFBUSxFQUFDLE1BQU0sdUJBQXVCLENBQUM7OztBQUUvQzs7Ozs7O0dBTUc7QUFFSCxNQUFNLE9BQU8sMEJBQTJCLFNBQVEsZ0JBQWdCO0lBSTlELFlBQThCLFNBQWMsRUFBRSxRQUFrQjtRQUM5RCxLQUFLLENBQUMsU0FBUyxFQUFFLFFBQVEsQ0FBQyxDQUFDO0lBQzdCLENBQUM7SUFFUSxXQUFX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