diff options
author | Sam Potts <me@sampotts.me> | 2017-11-06 22:00:00 +1100 |
---|---|---|
committer | Sam Potts <me@sampotts.me> | 2017-11-06 22:00:00 +1100 |
commit | 84505da84ba97ae1b189f9c695228d324e9dc3b8 (patch) | |
tree | 620a453bcd537355f1057b6f627ae2775d4dc093 /src/js/utils.js | |
parent | 2497e25b3ce6849986c3501354636fdae11df6d4 (diff) | |
download | plyr-84505da84ba97ae1b189f9c695228d324e9dc3b8.tar.lz plyr-84505da84ba97ae1b189f9c695228d324e9dc3b8.tar.xz plyr-84505da84ba97ae1b189f9c695228d324e9dc3b8.zip |
Automatic Vimeo aspect ratio
Diffstat (limited to 'src/js/utils.js')
-rw-r--r-- | src/js/utils.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/js/utils.js b/src/js/utils.js index 70519fac..1c3d6ed8 100644 --- a/src/js/utils.js +++ b/src/js/utils.js @@ -631,6 +631,13 @@ const utils = { return fragment.firstChild.innerText; }, + // Get aspect ratio for dimensions + getAspectRatio(width, height) { + const getRatio = (w, h) => (h === 0 ? w : getRatio(h, w % h)); + const ratio = getRatio(width, height); + return `${width / ratio}:${height / ratio}`; + }, + // Get the transition end event transitionEnd: (() => { const element = document.createElement('span'); |