diff options
author | KillyMXI | 2017-06-17 20:33:07 +0300 |
---|---|---|
committer | KillyMXI | 2017-06-17 20:33:07 +0300 |
commit | 897a351eb36ece8e6f9d2ccd8946ccfe9b7cfeea (patch) | |
tree | 21d6de31c1bfe9d948731364d221ea9ff9783a8f /juick-www/src/main/js | |
parent | 1dad7c9928291ed19021b9f118dbe6dd736017ba (diff) |
juick-www: fix for zero-height embeds in folded tree
do not resize element before its width is known
Diffstat (limited to 'juick-www/src/main/js')
-rw-r--r-- | juick-www/src/main/js/killy/index.js | 10 |
1 files changed, 7 insertions, 3 deletions
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() { |