Skip to content

Commit f818307

Browse files
committed
fix: optimize scroll position observer after video fullscreen exit
1 parent fbb3ed5 commit f818307

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/courseware/course/sequence/Unit/hooks/useIFrameBehavior.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,19 @@ const useIFrameBehavior = ({
5050
if (type === messageTypes.resize) {
5151
setIframeHeight(payload.height);
5252

53-
// We observe exit from the video xblock fullscreen mode
54-
// and scroll to the previously saved scroll position
55-
if (windowTopOffset !== null) {
56-
window.scrollTo(0, Number(windowTopOffset));
57-
}
58-
5953
if (!hasLoaded && iframeHeight === 0 && payload.height > 0) {
6054
setHasLoaded(true);
6155
if (onLoaded) {
6256
onLoaded();
6357
}
6458
}
6559
} else if (type === messageTypes.videoFullScreen) {
60+
// We observe exit from the video xblock fullscreen mode
61+
// and scroll to the previously saved scroll position
62+
if (!payload.open && windowTopOffset !== null) {
63+
window.scrollTo(0, Number(windowTopOffset));
64+
}
65+
6666
// We listen for this message from LMS to know when we need to
6767
// save or reset scroll position on toggle video xblock fullscreen mode
6868
setWindowTopOffset(payload.open ? window.scrollY : null);

0 commit comments

Comments
 (0)