Skip to content

Commit 42e84e3

Browse files
ihor-romaniukleangseu-edx
authored andcommitted
fix: save scroll position on exit from video xblock fullscreen mode
1 parent 62652c7 commit 42e84e3

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

xmodule/js/src/video/04_video_full_screen.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,21 @@
161161
return this.videoFullScreen.height;
162162
}
163163

164-
/**
164+
function notifyParent(fullscreenOpen) {
165+
if (window !== window.parent) {
166+
// This is used by the Learning MFE to know about changing fullscreen mode.
167+
// The MFE is then able to respond appropriately and scroll window to the previous position.
168+
window.parent.postMessage({
169+
type: 'plugin.videoFullScreen',
170+
payload: {
171+
open: fullscreenOpen
172+
}
173+
}, document.referrer
174+
);
175+
}
176+
}
177+
178+
/**
165179
* Event handler to toggle fullscreen mode.
166180
* @param {jquery Event} event
167181
*/
@@ -192,6 +206,8 @@
192206
this.resizer.delta.reset().setMode('width');
193207
}
194208
this.el.trigger('fullscreen', [this.isFullScreen]);
209+
210+
this.videoFullScreen.notifyParent(false);
195211
}
196212

197213
function handleEnter() {
@@ -202,6 +218,8 @@
202218
return;
203219
}
204220

221+
this.videoFullScreen.notifyParent(true);
222+
205223
this.videoFullScreen.fullScreenState = this.isFullScreen = true;
206224
fullScreenClassNameEl.addClass('video-fullscreen');
207225
this.videoFullScreen.fullScreenEl
@@ -267,7 +285,8 @@
267285
handleFullscreenChange: handleFullscreenChange,
268286
toggle: toggle,
269287
toggleHandler: toggleHandler,
270-
updateControlsHeight: updateControlsHeight
288+
updateControlsHeight: updateControlsHeight,
289+
notifyParent: notifyParent
271290
};
272291

273292
state.bindTo(methodsDict, state.videoFullScreen, state);

0 commit comments

Comments
 (0)