Skip to content

Commit a19ad69

Browse files
committed
Fix for Vimeo fullscreen with non 16:9 aspect ratios
1 parent d6f20e2 commit a19ad69

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

src/js/plugins/vimeo.js

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,9 @@ const vimeo = {
7070
// Set aspect ratio
7171
// For Vimeo we have an extra 300% height <div> to hide the standard controls and UI
7272
setAspectRatio(input) {
73-
const [x, y] = (is.string(input) ? input : this.config.ratio).split(':');
73+
const [x, y] = (is.string(input) ? input : this.config.ratio).split(':').map(Number);
7474
const padding = (100 / x) * y;
75+
vimeo.padding = padding;
7576
this.elements.wrapper.style.paddingBottom = `${padding}%`;
7677

7778
if (this.supported.ui) {
@@ -299,8 +300,8 @@ const vimeo = {
299300

300301
// Set aspect ratio based on video size
301302
Promise.all([player.embed.getVideoWidth(), player.embed.getVideoHeight()]).then(dimensions => {
302-
const ratio = getAspectRatio(dimensions[0], dimensions[1]);
303-
vimeo.setAspectRatio.call(this, ratio);
303+
vimeo.ratio = getAspectRatio(dimensions[0], dimensions[1]);
304+
vimeo.setAspectRatio.call(this, vimeo.ratio);
304305
});
305306

306307
// Set autopause
@@ -404,6 +405,22 @@ const vimeo = {
404405
triggerEvent.call(player, player.media, 'error');
405406
});
406407

408+
// Set height/width on fullscreen
409+
player.on('enterfullscreen exitfullscreen', event => {
410+
const { target } = player.fullscreen;
411+
412+
// Ignore for iOS native
413+
if (target !== player.elements.container) {
414+
return;
415+
}
416+
417+
const toggle = event.type === 'enterfullscreen';
418+
const [x, y] = vimeo.ratio.split(':').map(Number);
419+
const dimension = x > y ? 'width' : 'height';
420+
421+
target.style[dimension] = toggle ? `${vimeo.padding}%` : null;
422+
});
423+
407424
// Rebuild UI
408425
setTimeout(() => ui.build.call(player), 0);
409426
},

0 commit comments

Comments
 (0)