Skip to content

Commit

Permalink
Merge pull request #736 from samvera-labs/mobile-zoom
Browse files Browse the repository at this point in the history
Use resize event on window.visualViewport to adjust control-bar width for mobile devices
  • Loading branch information
Dananji authored Dec 3, 2024
2 parents a623fba + 18909ce commit 6c4f911
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/services/ramp-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,10 +487,21 @@ export const useVideoJSPlayer = ({
}
});

// Listen for resize events and trigger player.resize event
// Listen for resize events on desktop browsers and trigger player.resize event
window.addEventListener('resize', () => {
player.trigger('resize');
});

/**
* The 'resize' event on window doesn't catch zoom in/out in iOS Safari.
* Therefore, use window.visualViewport to detect zoom in/out in mobile browsers when
* zoomed in/out using OS/browser settings.
*/
if (window.visualViewport) {
window.visualViewport.addEventListener('resize', () => {
player.trigger('resize');
});
}
};

/**
Expand Down

0 comments on commit 6c4f911

Please sign in to comment.