Skip to content

Commit

Permalink
Merge pull request #760 from samvera-labs/switching-manifests-bug
Browse files Browse the repository at this point in the history
Check player is not null before player.trigger('resize') event
  • Loading branch information
Dananji authored Jan 13, 2025
2 parents e0064dd + dac1543 commit 09285aa
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/services/ramp-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ export const useVideoJSPlayer = ({

// Listen for resize events on desktop browsers and trigger player.resize event
window.addEventListener('resize', () => {
player.trigger('resize');
// Check if player is initialized before triggering resize event, especially helpful
// when switching the Manifest in the demo site without a page reload
if (player?.player_) player.trigger('resize');
});

/**
Expand All @@ -499,7 +501,9 @@ export const useVideoJSPlayer = ({
*/
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', () => {
player.trigger('resize');
// Check if player is initialized before triggering resize event, especially helpful
// when switching the Manifest in the demo site without a page reload
if (player?.player_) player.trigger('resize');
});
}
};
Expand Down

0 comments on commit 09285aa

Please sign in to comment.