aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
authorAlex Yatskov <FooSoft@users.noreply.github.com>2019-06-26 14:17:01 -0700
committerGitHub <noreply@github.com>2019-06-26 14:17:01 -0700
commit654b059b74fd0307fef8f674a9a6e27660660793 (patch)
tree7a163cd44f0a2a0068c4ea37b733cdd6c213aa4a /ext/fg/js
parentf77ac32fe1fa762d064e9809ba5439f25f996a6a (diff)
parent2974b592ab21ea8a2468cc1c89614652119d9c22 (diff)
Merge pull request #165 from toasted-nutbread/fullscreen-support
Allow popup window to be visible in fullscreen mode
Diffstat (limited to 'ext/fg/js')
-rw-r--r--ext/fg/js/popup.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index d2acf4d0..ad81cf03 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -33,7 +33,8 @@ class Popup {
if (!this.injected) {
this.injected = new Promise((resolve, reject) => {
this.container.addEventListener('load', resolve);
- document.body.appendChild(this.container);
+ this.observeFullscreen();
+ this.onFullscreenChanged();
});
}
@@ -138,4 +139,32 @@ class Popup {
invokeApi(action, params={}) {
this.container.contentWindow.postMessage({action, params}, '*');
}
+
+ observeFullscreen() {
+ const fullscreenEvents = [
+ 'fullscreenchange',
+ 'MSFullscreenChange',
+ 'mozfullscreenchange',
+ 'webkitfullscreenchange'
+ ];
+ for (const eventName of fullscreenEvents) {
+ document.addEventListener(eventName, () => this.onFullscreenChanged(), false);
+ }
+ }
+
+ getFullscreenElement() {
+ return (
+ document.fullscreenElement ||
+ document.msFullscreenElement ||
+ document.mozFullScreenElement ||
+ document.webkitFullscreenElement
+ );
+ }
+
+ onFullscreenChanged() {
+ const parent = (this.getFullscreenElement() || document.body || null);
+ if (parent !== null && this.container.parentNode !== parent) {
+ parent.appendChild(this.container);
+ }
+ }
}