From 897a351eb36ece8e6f9d2ccd8946ccfe9b7cfeea Mon Sep 17 00:00:00 2001 From: KillyMXI Date: Sat, 17 Jun 2017 20:33:07 +0300 Subject: juick-www: fix for zero-height embeds in folded tree do not resize element before its width is known --- juick-www/src/main/js/killy/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'juick-www/src/main/js/killy') diff --git a/juick-www/src/main/js/killy/index.js b/juick-www/src/main/js/killy/index.js index 1a59805d..46798c9f 100644 --- a/juick-www/src/main/js/killy/index.js +++ b/juick-www/src/main/js/killy/index.js @@ -40,9 +40,13 @@ function makeResizableToRatio(element, ratio) { // calcHeight :: Number -> Number -- calculate element height for a given width function makeResizable(element, calcHeight) { - const resizeToRatio = el => { el.style.height = (calcHeight(el.offsetWidth)).toFixed(2) + 'px'; }; - window.addEventListener('resize', () => resizeToRatio(element)); - resizeToRatio(element); + const setHeight = el => { + if (el.offsetWidth > 0) { + el.style.height = (calcHeight(el.offsetWidth)).toFixed(2) + 'px'; + } + }; + window.addEventListener('resize', () => setHeight(element)); + setHeight(element); } function getEmbeddableLinkTypes() { -- cgit v1.2.3