From 97d9228bed639f0c20b1f21468dd3f181af6b262 Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Mon, 3 Jun 2019 20:13:16 +1000 Subject: Aspect ratio tweaks --- src/js/utils/style.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'src/js/utils/style.js') diff --git a/src/js/utils/style.js b/src/js/utils/style.js index 6f3069c9..941db8f2 100644 --- a/src/js/utils/style.js +++ b/src/js/utils/style.js @@ -27,15 +27,8 @@ export function reduceAspectRatio(ratio) { } export function getAspectRatio(input) { - const parse = ratio => { - if (!validateRatio(ratio)) { - return null; - } - - return ratio.split(':').map(Number); - }; - - // Provided ratio + const parse = ratio => (validateRatio(ratio) ? ratio.split(':').map(Number) : null); + // Try provided ratio let ratio = parse(input); // Get from config -- cgit v1.2.3 From f8a28b632cf12a2c557a766010252b9edd4cdb8e Mon Sep 17 00:00:00 2001 From: Sam Potts Date: Sun, 26 Jan 2020 22:05:21 +0000 Subject: Audio style fix --- src/js/utils/style.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/js/utils/style.js') diff --git a/src/js/utils/style.js b/src/js/utils/style.js index 941db8f2..17a033fe 100644 --- a/src/js/utils/style.js +++ b/src/js/utils/style.js @@ -56,11 +56,12 @@ export function setAspectRatio(input) { return {}; } + const { wrapper } = this.elements; const ratio = getAspectRatio.call(this, input); const [w, h] = is.array(ratio) ? ratio : [0, 0]; const padding = (100 / w) * h; - this.elements.wrapper.style.paddingBottom = `${padding}%`; + wrapper.style.paddingBottom = `${padding}%`; // For Vimeo we have an extra
to hide the standard controls and UI if (this.isVimeo && this.supported.ui) { @@ -68,7 +69,7 @@ export function setAspectRatio(input) { const offset = (height - padding) / (height / 50); this.media.style.transform = `translateY(-${offset}%)`; } else if (this.isHTML5) { - this.elements.wrapper.classList.toggle(this.config.classNames.videoFixedRatio, ratio !== null); + wrapper.classList.toggle(this.config.classNames.videoFixedRatio, ratio !== null); } return { padding, ratio }; -- cgit v1.2.3