Browse Source

Update fullscreen.js

Karl Chen 7 years ago
parent
commit
8b9cc21c96
1 changed files with 9 additions and 10 deletions
  1. 9 10
      src/fullscreen.js

+ 9 - 10
src/fullscreen.js

@@ -36,8 +36,10 @@ class FullScreen {
         }
     }
 
-    request (type = 'browser', switchmode) {
-        if (!switchmode) {
+    request (type = 'browser') {
+        const anotherType = type === 'browser' ? 'web' : 'browser';
+        this.anotherTypeOn = this.isFullScreen(anotherType);
+        if (!this.anotherTypeOn) {
             this.lastScrollPosition = utils.getScrollPosition();
         }
 
@@ -62,6 +64,10 @@ class FullScreen {
             this.player.events.trigger('webfullscreen');
             break;
         }
+
+        if (this.anotherTypeOn) {
+            this.cancel(anotherType);
+        }
     }
 
     cancel (type = 'browser') {
@@ -90,14 +96,7 @@ class FullScreen {
             this.cancel(type);
         }
         else {
-            const anotherType = type === 'browser' ? 'web' : 'browser';
-            if (this.isFullScreen(anotherType)) {
-                this.request(type, true);
-                this.cancel(anotherType);
-            }
-            else {
-                this.request(type);
-            }
+            this.request(type);
         }
     }
 }