Skip to content

Commit 6c56792

Browse files
committed
fix(video-engagement): video player controls buttons shift position in fullscreen on mobile.
In mobile view, when a video has engagement options enabled and the comment box is open, the player controls (pause and seek/forward) change position unexpectedly when entering fullscreen.
1 parent a27f896 commit 6c56792

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

assets/src/js/godam-player/engagement.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,6 +1191,29 @@ function CommentBox( props ) {
11911191
videoContainer.appendChild( currentVideo );
11921192
document.body.classList.add( 'no-scroll' );
11931193

1194+
// Trigger a resize after moving the current video into the modal container
1195+
// to reposition the skip control buttons according to the new dimensions,
1196+
// particularly for mobile devices.
1197+
let resizeHandled = false;
1198+
// Prefer triggering a scoped resize on the Video.js player instance
1199+
// instead of dispatching a global window resize event.
1200+
const videoElement = videoContainer?.querySelector( 'video' );
1201+
if (
1202+
videoElement &&
1203+
typeof window.videojs !== 'undefined' &&
1204+
typeof window.videojs.getPlayer === 'function'
1205+
) {
1206+
const player = window.videojs.getPlayer( videoElement );
1207+
if ( player && typeof player.trigger === 'function' ) {
1208+
player.trigger( 'resize' );
1209+
resizeHandled = true;
1210+
}
1211+
}
1212+
// Fallback: if the Video.js player instance cannot be resolved,
1213+
// dispatch a global window resize event.
1214+
if ( ! resizeHandled ) {
1215+
window.dispatchEvent( new Event( 'resize' ) );
1216+
}
11941217
return () => {
11951218
if ( currentVideoParent && currentVideo ) {
11961219
currentVideoParent.insertBefore( currentVideo, currentVideoParent.firstChild );

0 commit comments

Comments
 (0)