1 | /**
|
---|
2 | * @license
|
---|
3 | * Copyright Google LLC All Rights Reserved.
|
---|
4 | *
|
---|
5 | * Use of this source code is governed by an MIT-style license that can be
|
---|
6 | * found in the LICENSE file at https://angular.io/license
|
---|
7 | */
|
---|
8 | import { Injectable, Inject } from '@angular/core';
|
---|
9 | import { OverlayContainer } from './overlay-container';
|
---|
10 | import { DOCUMENT } from '@angular/common';
|
---|
11 | import { Platform } from '@angular/cdk/platform';
|
---|
12 | import * as i0 from "@angular/core";
|
---|
13 | import * as i1 from "@angular/common";
|
---|
14 | import * as i2 from "@angular/cdk/platform";
|
---|
15 | /**
|
---|
16 | * Alternative to OverlayContainer that supports correct displaying of overlay elements in
|
---|
17 | * Fullscreen mode
|
---|
18 | * https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen
|
---|
19 | *
|
---|
20 | * Should be provided in the root component.
|
---|
21 | */
|
---|
22 | export class FullscreenOverlayContainer extends OverlayContainer {
|
---|
23 | constructor(_document, platform) {
|
---|
24 | super(_document, platform);
|
---|
25 | }
|
---|
26 | ngOnDestroy() {
|
---|
27 | super.ngOnDestroy();
|
---|
28 | if (this._fullScreenEventName && this._fullScreenListener) {
|
---|
29 | this._document.removeEventListener(this._fullScreenEventName, this._fullScreenListener);
|
---|
30 | }
|
---|
31 | }
|
---|
32 | _createContainer() {
|
---|
33 | super._createContainer();
|
---|
34 | this._adjustParentForFullscreenChange();
|
---|
35 | this._addFullscreenChangeListener(() => this._adjustParentForFullscreenChange());
|
---|
36 | }
|
---|
37 | _adjustParentForFullscreenChange() {
|
---|
38 | if (!this._containerElement) {
|
---|
39 | return;
|
---|
40 | }
|
---|
41 | const fullscreenElement = this.getFullscreenElement();
|
---|
42 | const parent = fullscreenElement || this._document.body;
|
---|
43 | parent.appendChild(this._containerElement);
|
---|
44 | }
|
---|
45 | _addFullscreenChangeListener(fn) {
|
---|
46 | const eventName = this._getEventName();
|
---|
47 | if (eventName) {
|
---|
48 | if (this._fullScreenListener) {
|
---|
49 | this._document.removeEventListener(eventName, this._fullScreenListener);
|
---|
50 | }
|
---|
51 | this._document.addEventListener(eventName, fn);
|
---|
52 | this._fullScreenListener = fn;
|
---|
53 | }
|
---|
54 | }
|
---|
55 | _getEventName() {
|
---|
56 | if (!this._fullScreenEventName) {
|
---|
57 | const _document = this._document;
|
---|
58 | if (_document.fullscreenEnabled) {
|
---|
59 | this._fullScreenEventName = 'fullscreenchange';
|
---|
60 | }
|
---|
61 | else if (_document.webkitFullscreenEnabled) {
|
---|
62 | this._fullScreenEventName = 'webkitfullscreenchange';
|
---|
63 | }
|
---|
64 | else if (_document.mozFullScreenEnabled) {
|
---|
65 | this._fullScreenEventName = 'mozfullscreenchange';
|
---|
66 | }
|
---|
67 | else if (_document.msFullscreenEnabled) {
|
---|
68 | this._fullScreenEventName = 'MSFullscreenChange';
|
---|
69 | }
|
---|
70 | }
|
---|
71 | return this._fullScreenEventName;
|
---|
72 | }
|
---|
73 | /**
|
---|
74 | * When the page is put into fullscreen mode, a specific element is specified.
|
---|
75 | * Only that element and its children are visible when in fullscreen mode.
|
---|
76 | */
|
---|
77 | getFullscreenElement() {
|
---|
78 | const _document = this._document;
|
---|
79 | return _document.fullscreenElement ||
|
---|
80 | _document.webkitFullscreenElement ||
|
---|
81 | _document.mozFullScreenElement ||
|
---|
82 | _document.msFullscreenElement ||
|
---|
83 | null;
|
---|
84 | }
|
---|
85 | }
|
---|
86 | FullscreenOverlayContainer.ɵprov = i0.ɵɵdefineInjectable({ factory: function FullscreenOverlayContainer_Factory() { return new FullscreenOverlayContainer(i0.ɵɵinject(i1.DOCUMENT), i0.ɵɵinject(i2.Platform)); }, token: FullscreenOverlayContainer, providedIn: "root" });
|
---|
87 | FullscreenOverlayContainer.decorators = [
|
---|
88 | { type: Injectable, args: [{ providedIn: 'root' },] }
|
---|
89 | ];
|
---|
90 | FullscreenOverlayContainer.ctorParameters = () => [
|
---|
91 | { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
---|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