Aspect ratio improvements (fixes #1042, fixes #1366)

This commit is contained in:
Sam Potts
2019-04-12 12:19:48 +10:00
parent 9ca7b861a9
commit b247093495
8 changed files with 109 additions and 33 deletions

View File

@ -9,7 +9,7 @@ import browser from './utils/browser';
import { getElement, getElements, matches, toggleClass, toggleHidden } from './utils/elements';
import { off, on, once, toggleListener, triggerEvent } from './utils/events';
import is from './utils/is';
import { setAspectRatio } from './utils/style';
import { getAspectRatio, setAspectRatio } from './utils/style';
class Listeners {
constructor(player) {
@ -317,10 +317,10 @@ class Listeners {
}
const target = player.elements.wrapper.firstChild;
const [, height] = ratio.split(':').map(Number);
const [videoWidth, videoHeight] = player.embed.ratio.split(':').map(Number);
const [, y] = ratio;
const [videoX, videoY] = getAspectRatio.call(this);
target.style.maxWidth = toggle ? `${(height / videoHeight) * videoWidth}px` : null;
target.style.maxWidth = toggle ? `${(y / videoY) * videoX}px` : null;
target.style.margin = toggle ? '0 auto' : null;
};