UNPKG

@angular/cdk

Version:

Angular Material Component Development Kit

1 lines 5.07 kB
{"version":3,"file":"overlay.mjs","sources":["../../../../../k8-fastbuild-ST-46c76129e412/bin/src/cdk/overlay/fullscreen-overlay-container.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {inject, Injectable, OnDestroy, RendererFactory2} from '@angular/core';\nimport {OverlayContainer} from './overlay-container';\n\n/**\n * Alternative to OverlayContainer that supports correct displaying of overlay elements in\n * Fullscreen mode\n * https://developer.mozilla.org/en-US/docs/Web/API/Element/requestFullScreen\n *\n * Should be provided in the root component.\n */\n@Injectable({providedIn: 'root'})\nexport class FullscreenOverlayContainer extends OverlayContainer implements OnDestroy {\n private _renderer = inject(RendererFactory2).createRenderer(null, null);\n private _fullScreenEventName: string | undefined;\n private _cleanupFullScreenListener: (() => void) | undefined;\n\n constructor(...args: unknown[]);\n\n constructor() {\n super();\n }\n\n override ngOnDestroy() {\n super.ngOnDestroy();\n this._cleanupFullScreenListener?.();\n }\n\n protected override _createContainer(): void {\n const eventName = this._getEventName();\n super._createContainer();\n this._adjustParentForFullscreenChange();\n\n if (eventName) {\n this._cleanupFullScreenListener?.();\n this._cleanupFullScreenListener = this._renderer.listen('document', eventName, () => {\n this._adjustParentForFullscreenChange();\n });\n }\n }\n\n private _adjustParentForFullscreenChange(): void {\n if (this._containerElement) {\n const fullscreenElement = this.getFullscreenElement();\n const parent = fullscreenElement || this._document.body;\n parent.appendChild(this._containerElement);\n }\n }\n\n private _getEventName(): string | undefined {\n if (!this._fullScreenEventName) {\n const _document = this._document as any;\n\n if (_document.fullscreenEnabled) {\n this._fullScreenEventName = 'fullscreenchange';\n } else if (_document.webkitFullscreenEnabled) {\n this._fullScreenEventName = 'webkitfullscreenchange';\n } else if (_document.mozFullScreenEnabled) {\n this._fullScreenEventName = 'mozfullscreenchange';\n } else if (_document.msFullscreenEnabled) {\n this._fullScreenEventName = 'MSFullscreenChange';\n }\n }\n\n return this._fullScreenEventName;\n }\n\n /**\n * When the page is put into fullscreen mode, a specific element is specified.\n * Only that element and its children are visible when in fullscreen mode.\n */\n getFullscreenElement(): Element {\n const _document = this._document as any;\n\n return (\n _document.fullscreenElement ||\n _document.webkitFullscreenElement ||\n _document.mozFullScreenElement ||\n _document.msFullscreenElement ||\n null\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAWA;;;;;;AAMG;AAEG,MAAO,0BAA2B,SAAQ,gBAAgB,CAAA;AACtD,IAAA,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;AAC/D,IAAA,oBAAoB,CAAA;AACpB,IAAA,0BAA0B,CAAA;AAIlC,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE,CAAA;KACT;IAES,WAAW,GAAA;QAClB,KAAK,CAAC,WAAW,EAAE,CAAA;AACnB,QAAA,IAAI,CAAC,0BAA0B,IAAI,CAAA;KACrC;IAEmB,gBAAgB,GAAA;AACjC,QAAA,MAAM,SAAS,GAAG,IAAI,CAAC,aAAa,EAAE,CAAA;QACtC,KAAK,CAAC,gBAAgB,EAAE,CAAA;QACxB,IAAI,CAAC,gCAAgC,EAAE,CAAA;QAEvC,IAAI,SAAS,EAAE;AACb,YAAA,IAAI,CAAC,0BAA0B,IAAI,CAAA;AACnC,YAAA,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,MAAK;gBAClF,IAAI,CAAC,gCAAgC,EAAE,CAAA;AACzC,aAAC,CAAC,CAAA;SACJ;KACF;IAEQ,gCAAgC,GAAA;AACtC,QAAA,IAAI,IAAI,CAAC,iBAAiB,EAAE;AAC1B,YAAA,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAA;YACr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