probably a better solution than using a timeout

This commit is contained in:
Kendall Werts 2019-08-28 08:39:53 -05:00
parent 529b9bb482
commit 21b7386a94

View file

@ -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");
}
});