From 01bea4ac30ea1b676520cff40d85761581384e94 Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Sun, 24 Dec 2017 09:54:34 +0800 Subject: [PATCH 1/4] fix fullscreen switch logic --- src/fullscreen.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/fullscreen.js b/src/fullscreen.js index dcfa02a..e4904f7 100644 --- a/src/fullscreen.js +++ b/src/fullscreen.js @@ -8,6 +8,7 @@ class FullScreen { this.player.resize(); }); this.player.events.on('webfullscreen_cancel', () => { + utils.setScrollPosition(this.lastScrollPosition); this.player.resize(); }); @@ -17,6 +18,7 @@ class FullScreen { this.player.events.trigger('fullscreen'); } else { + utils.setScrollPosition(this.lastScrollPosition); this.player.events.trigger('fullscreen_cancel'); } }; @@ -34,7 +36,11 @@ class FullScreen { } } - request (type = 'browser') { + request (type = 'browser', switchmode) { + if (!switchmode) { + this.lastScrollPosition = utils.getScrollPosition(); + } + switch (type) { case 'browser': if (this.player.container.requestFullscreen) { @@ -52,11 +58,7 @@ class FullScreen { break; case 'web': this.player.container.classList.add('dplayer-fulled'); - - // record last position then hide scrollbars - this.lastScrollPosition = utils.getScrollPosition(); document.body.classList.add('dplayer-web-fullscreen-fix'); - this.player.events.trigger('webfullscreen'); break; } @@ -77,11 +79,7 @@ class FullScreen { break; case 'web': this.player.container.classList.remove('dplayer-fulled'); - - // restore scrollbars and last position document.body.classList.remove('dplayer-web-fullscreen-fix'); - utils.setScrollPosition(this.lastScrollPosition); - this.player.events.trigger('webfullscreen_cancel'); break; } @@ -92,11 +90,14 @@ class FullScreen { this.cancel(type); } else { - this.request(type); const anotherType = type === 'browser' ? 'web' : 'browser'; if (this.isFullScreen(anotherType)) { + this.request(type, true); this.cancel(anotherType); } + else { + this.request(type); + } } } } From 212db32d050d05003119e64270eee2157db3b8af Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Sun, 24 Dec 2017 09:58:18 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=BF=8E=E5=90=88=E4=BB=A5=E5=89=8D?= =?UTF-8?q?=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/fullscreen.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fullscreen.js b/src/fullscreen.js index e4904f7..065f33a 100644 --- a/src/fullscreen.js +++ b/src/fullscreen.js @@ -8,8 +8,8 @@ class FullScreen { this.player.resize(); }); this.player.events.on('webfullscreen_cancel', () => { - utils.setScrollPosition(this.lastScrollPosition); this.player.resize(); + utils.setScrollPosition(this.lastScrollPosition); }); const fullscreenchange = () => { From 8b9cc21c96990ce790621bf59429889725abf640 Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Sun, 24 Dec 2017 13:50:37 +0800 Subject: [PATCH 3/4] Update fullscreen.js --- src/fullscreen.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/fullscreen.js b/src/fullscreen.js index 065f33a..72f51e7 100644 --- a/src/fullscreen.js +++ b/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); } } } From 3ddbece5d141db0b6ccf237b71d7cd0801efe74c Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Sun, 24 Dec 2017 13:58:15 +0800 Subject: [PATCH 4/4] Update fullscreen.js --- src/fullscreen.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fullscreen.js b/src/fullscreen.js index 72f51e7..3719ff9 100644 --- a/src/fullscreen.js +++ b/src/fullscreen.js @@ -38,8 +38,8 @@ class FullScreen { request (type = 'browser') { const anotherType = type === 'browser' ? 'web' : 'browser'; - this.anotherTypeOn = this.isFullScreen(anotherType); - if (!this.anotherTypeOn) { + const anotherTypeOn = this.isFullScreen(anotherType); + if (!anotherTypeOn) { this.lastScrollPosition = utils.getScrollPosition(); } @@ -65,7 +65,7 @@ class FullScreen { break; } - if (this.anotherTypeOn) { + if (anotherTypeOn) { this.cancel(anotherType); } }