UNPKG

7.11 kBSource Map (JSON)View Raw
1{"version":3,"file":"lg-fullscreen.es5.js","sources":["../../../src/plugins/fullscreen/lg-fullscreen-settings.ts","../../../src/plugins/fullscreen/lg-fullscreen.ts"],"sourcesContent":["export interface FullscreenStrings {\n toggleFullscreen: string;\n}\nexport interface FullscreenSettings {\n /**\n * Enable/Disable fullscreen option\n */\n fullScreen: boolean;\n\n /**\n * Custom translation strings for aria-labels\n */\n fullscreenPluginStrings: FullscreenStrings;\n}\n\nexport const fullscreenSettings: FullscreenSettings = {\n fullScreen: true,\n fullscreenPluginStrings: {\n toggleFullscreen: 'Toggle Fullscreen',\n } as FullscreenStrings,\n};\n","import { LgQuery } from '../../lgQuery';\nimport { LightGallery } from '../../lightgallery';\nimport {\n FullscreenSettings,\n fullscreenSettings,\n} from './lg-fullscreen-settings';\n\ndeclare let document: any;\n\nexport default class FullScreen {\n core: LightGallery;\n settings: FullscreenSettings;\n private $LG!: LgQuery;\n constructor(instance: LightGallery, $LG: LgQuery) {\n // get lightGallery core plugin instance\n this.core = instance;\n this.$LG = $LG;\n\n // extend module default settings with lightGallery core settings\n this.settings = { ...fullscreenSettings, ...this.core.settings };\n\n return this;\n }\n\n public init(): void {\n let fullScreen = '';\n if (this.settings.fullScreen) {\n // check for fullscreen browser support\n if (\n !document.fullscreenEnabled &&\n !document.webkitFullscreenEnabled &&\n !document.mozFullScreenEnabled &&\n !document.msFullscreenEnabled\n ) {\n return;\n } else {\n fullScreen = `<button type=\"button\" aria-label=\"${this.settings.fullscreenPluginStrings['toggleFullscreen']}\" class=\"lg-fullscreen lg-icon\"></button>`;\n this.core.$toolbar.append(fullScreen);\n this.fullScreen();\n }\n }\n }\n\n private isFullScreen(): boolean {\n return (\n document.fullscreenElement ||\n document.mozFullScreenElement ||\n document.webkitFullscreenElement ||\n document.msFullscreenElement\n );\n }\n\n private requestFullscreen(): void {\n const el = document.documentElement;\n if (el.requestFullscreen) {\n el.requestFullscreen();\n } else if (el.msRequestFullscreen) {\n el.msRequestFullscreen();\n } else if (el.mozRequestFullScreen) {\n el.mozRequestFullScreen();\n } else if (el.webkitRequestFullscreen) {\n el.webkitRequestFullscreen();\n }\n }\n\n private exitFullscreen(): void {\n if (document.exitFullscreen) {\n document.exitFullscreen();\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen();\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if (document.webkitExitFullscreen) {\n document.webkitExitFullscreen();\n }\n }\n\n // https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode\n private fullScreen(): void {\n this.$LG(document).on(\n `fullscreenchange.lg.global${this.core.lgId} \n webkitfullscreenchange.lg.global${this.core.lgId} \n mozfullscreenchange.lg.global${this.core.lgId} \n MSFullscreenChange.lg.global${this.core.lgId}`,\n () => {\n if (!this.core.lgOpened) return;\n this.core.outer.toggleClass('lg-fullscreen-on');\n },\n );\n\n this.core.outer\n .find('.lg-fullscreen')\n .first()\n .on('click.lg', () => {\n if (this.isFullScreen()) {\n this.exitFullscreen();\n } else {\n this.requestFullscreen();\n }\n });\n }\n\n closeGallery(): void {\n // exit from fullscreen if activated\n if (this.isFullScreen()) {\n this.exitFullscreen();\n }\n }\n\n destroy(): void {\n this.$LG(document).off(\n `fullscreenchange.lg.global${this.core.lgId} \n webkitfullscreenchange.lg.global${this.core.lgId} \n mozfullscreenchange.lg.global${this.core.lgId} \n MSFullscreenChange.lg.global${this.core.lgId}`,\n );\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeO,IAAM,kBAAkB,GAAuB;IAClD,UAAU,EAAE,IAAI;IAChB,uBAAuB,EAAE;QACrB,gBAAgB,EAAE,mBAAmB;KACnB;CACzB;;;ICPG,oBAAY,QAAsB,EAAE,GAAY;;QAE5C,IAAI,CAAC,IAAI,GAAG,QAAQ,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;;QAGf,IAAI,CAAC,QAAQ,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