From 21b7386a94d28150b268323753707bf8715afa5e Mon Sep 17 00:00:00 2001 From: Kendall Werts Date: Wed, 28 Aug 2019 08:39:53 -0500 Subject: [PATCH] probably a better solution than using a timeout --- src/js/popup.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/js/popup.js b/src/js/popup.js index 54c2c02..80986a2 100644 --- a/src/js/popup.js +++ b/src/js/popup.js @@ -290,16 +290,6 @@ const Logic = { } }); document.querySelector(this.getPanelSelector(this._panels[panel])).classList.remove("hide"); - window.setTimeout(function () { - //sometimes this executes before the window is there and window.innerWidth returns undefined - const difference = window.innerWidth - document.body.offsetWidth; - if (difference > 2) { - //if popup is in the overflow menu, window will be larger than 300px - const root = document.documentElement; - root.style.setProperty("--overflow-size", difference + "px"); - root.style.setProperty("--icon-fit", "12"); - } - }, 200); }, showPreviousPanel() { @@ -1154,3 +1144,14 @@ Logic.registerPanel(P_CONTAINERS_ACHIEVEMENT, { }); Logic.init(); + +window.addEventListener("resize", function () { + //for overflow menu + const difference = window.innerWidth - document.body.offsetWidth; + if (difference > 2) { + //if popup is in the overflow menu, window will be larger than 300px + const root = document.documentElement; + root.style.setProperty("--overflow-size", difference + "px"); + root.style.setProperty("--icon-fit", "12"); + } +}); \ No newline at end of file