Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: save scroll position on exit from video xblock fullscreen mode #31871

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion xmodule/js/src/video/04_video_full_screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@
return this.videoFullScreen.height;
}

function notifyParent(fullscreenOpen) {
if (window !== window.parent) {
// This is used by the Learning MFE to know about changing 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: fullscreenOpen
}
}, document.referrer
);
}
}

/**
* Event handler to toggle fullscreen mode.
* @param {jquery Event} event
Expand Down Expand Up @@ -192,6 +206,8 @@
this.resizer.delta.reset().setMode('width');
}
this.el.trigger('fullscreen', [this.isFullScreen]);

this.videoFullScreen.notifyParent(false);
}

function handleEnter() {
Expand All @@ -202,6 +218,8 @@
return;
}

this.videoFullScreen.notifyParent(true);

this.videoFullScreen.fullScreenState = this.isFullScreen = true;
fullScreenClassNameEl.addClass('video-fullscreen');
this.videoFullScreen.fullScreenEl
Expand Down Expand Up @@ -267,7 +285,8 @@
handleFullscreenChange: handleFullscreenChange,
toggle: toggle,
toggleHandler: toggleHandler,
updateControlsHeight: updateControlsHeight
updateControlsHeight: updateControlsHeight,
notifyParent: notifyParent,
};

state.bindTo(methodsDict, state.videoFullScreen, state);
Expand Down