blob: 5cd568b57122d2a811d6433b776d2d1da6adcc9f [file] [log] [blame]
Davit Tabidze014c6962024-06-07 18:37:04 +04001document.addEventListener("DOMContentLoaded", function () {
2 const page = document.documentElement;
3 const headerHeight = parseFloat(getComputedStyle(page).getPropertyValue('--pico-header-height').replace("px", ""));
4 const nav = document.getElementById("menu");
5 const windowHeight = window.innerHeight - headerHeight;
6 nav.style.setProperty("--max-height", `${windowHeight}px`);
Davit Tabidze56bcf252024-06-12 19:00:45 +04007 const menu = document.getElementById("menu-nav");
8 const menuHeight = parseFloat(getComputedStyle(document.getElementById('menu-nav')).height.replace("px", "")) + 15;
9 menu.style.setProperty("height", `${menuHeight}px`);
Davit Tabidze014c6962024-06-07 18:37:04 +040010});
11
12let prevWindowHeight = window.innerHeight;
13
14window.addEventListener("resize", function () {
15 const nav = document.getElementById("menu");
16 const windowHeight = window.innerHeight;
17 const heightDiff = prevWindowHeight - windowHeight;
18 const currentMaxHeight = parseFloat(nav.style.getPropertyValue("--max-height").replace("px", ""));
19 if (!isNaN(currentMaxHeight)) {
20 const newMaxHeight = currentMaxHeight - heightDiff;
21 nav.style.setProperty("--max-height", `${newMaxHeight}px`);
22 }
23 prevWindowHeight = windowHeight;
24});