diff options
author | Sam Potts <sam@potts.es> | 2019-04-12 12:19:48 +1000 |
---|---|---|
committer | Sam Potts <sam@potts.es> | 2019-04-12 12:19:48 +1000 |
commit | b247093495c3402dbe7c14e3faeff8475f4e277c (patch) | |
tree | 8db601f188caf539277f9760ca93d02e9deb442b /src/js/listeners.js | |
parent | 9ca7b861a925ec0412006f7cc926bfa1859a0daa (diff) | |
download | plyr-b247093495c3402dbe7c14e3faeff8475f4e277c.tar.lz plyr-b247093495c3402dbe7c14e3faeff8475f4e277c.tar.xz plyr-b247093495c3402dbe7c14e3faeff8475f4e277c.zip |
Aspect ratio improvements (fixes #1042, fixes #1366)
Diffstat (limited to 'src/js/listeners.js')
-rw-r--r-- | src/js/listeners.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/js/listeners.js b/src/js/listeners.js index 3c65b824..5a593b10 100644 --- a/src/js/listeners.js +++ b/src/js/listeners.js @@ -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; }; |