From efe40657b4f0444df7d14dacd87b447489b75fd8 Mon Sep 17 00:00:00 2001 From: ihor-romaniuk Date: Wed, 28 Sep 2022 18:03:46 +0300 Subject: [PATCH] fix: save scroll position on exit from video xblock fullscreen mode --- xmodule/js/src/video/04_video_full_screen.js | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/xmodule/js/src/video/04_video_full_screen.js b/xmodule/js/src/video/04_video_full_screen.js index 641485f4bd..85ec769e14 100644 --- a/xmodule/js/src/video/04_video_full_screen.js +++ b/xmodule/js/src/video/04_video_full_screen.js @@ -193,6 +193,18 @@ this.resizer.delta.reset().setMode('width'); } this.el.trigger('fullscreen', [this.isFullScreen]); + + if (window !== window.parent) { + // This is used by the Learning MFE to know about closing fullscreen mode. + // The MFE is then able to respond appropriately and scroll window to the previous position. + window.parent.postMessage({ + type: 'plugin.videoFullScreen', + payload: { + open: false + } + }, document.referrer + ); + } } function handleEnter() { @@ -203,6 +215,18 @@ return; } + if (window !== window.parent) { + // This is used by the Learning MFE to know about opening fullscreen mode. + // The MFE is then able to respond appropriately and save the window scroll position. + window.parent.postMessage({ + type: 'plugin.videoFullScreen', + payload: { + open: true + } + }, document.referrer + ); + } + this.videoFullScreen.fullScreenState = this.isFullScreen = true; fullScreenClassNameEl.addClass('video-fullscreen'); this.videoFullScreen.fullScreenEl