aboutsummaryrefslogtreecommitdiffstats
path: root/src/js
diff options
context:
space:
mode:
authorSam Potts <sam@potts.es>2018-11-08 23:19:11 +1100
committerSam Potts <sam@potts.es>2018-11-08 23:19:11 +1100
commita19ad6903855d1bb9585c0e8e4b97e65eff2c85a (patch)
tree56a0b95a12bda1d05288d454c6ecd7d90018bf2a /src/js
parentd6f20e27568f42828174848080a9e2f1fef5b056 (diff)
downloadplyr-a19ad6903855d1bb9585c0e8e4b97e65eff2c85a.tar.lz
plyr-a19ad6903855d1bb9585c0e8e4b97e65eff2c85a.tar.xz
plyr-a19ad6903855d1bb9585c0e8e4b97e65eff2c85a.zip
Fix for Vimeo fullscreen with non 16:9 aspect ratios
Diffstat (limited to 'src/js')
-rw-r--r--src/js/plugins/vimeo.js23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/js/plugins/vimeo.js b/src/js/plugins/vimeo.js
index 3c3dee20..2d9ba6e2 100644
--- a/src/js/plugins/vimeo.js
+++ b/src/js/plugins/vimeo.js
@@ -70,8 +70,9 @@ const vimeo = {
// Set aspect ratio
// For Vimeo we have an extra 300% height <div> to hide the standard controls and UI
setAspectRatio(input) {
- const [x, y] = (is.string(input) ? input : this.config.ratio).split(':');
+ const [x, y] = (is.string(input) ? input : this.config.ratio).split(':').map(Number);
const padding = (100 / x) * y;
+ vimeo.padding = padding;
this.elements.wrapper.style.paddingBottom = `${padding}%`;
if (this.supported.ui) {
@@ -299,8 +300,8 @@ const vimeo = {
// Set aspect ratio based on video size
Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then(dimensions => {
- const ratio = getAspectRatio(dimensions[0], dimensions[1]);
- vimeo.setAspectRatio.call(this, ratio);
+ vimeo.ratio = getAspectRatio(dimensions[0], dimensions[1]);
+ vimeo.setAspectRatio.call(this, vimeo.ratio);
});
// Set autopause
@@ -404,6 +405,22 @@ const vimeo = {
triggerEvent.call(player, player.media, 'error');
});
+ // Set height/width on fullscreen
+ player.on('enterfullscreen exitfullscreen', event => {
+ const { target } = player.fullscreen;
+
+ // Ignore for iOS native
+ if (target !== player.elements.container) {
+ return;
+ }
+
+ const toggle = event.type === 'enterfullscreen';
+ const [x, y] = vimeo.ratio.split(':').map(Number);
+ const dimension = x > y ? 'width' : 'height';
+
+ target.style[dimension] = toggle ? `${vimeo.padding}%` : null;
+ });
+
// Rebuild UI
setTimeout(() => ui.build.call(player), 0);
},