blob: ff10c1b68db90b76e88a65943bc10350db0a0330 [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`);
7});
8
9let prevWindowHeight = window.innerHeight;
10
11window.addEventListener("resize", function () {
12 const nav = document.getElementById("menu");
13 const windowHeight = window.innerHeight;
14 const heightDiff = prevWindowHeight - windowHeight;
15 const currentMaxHeight = parseFloat(nav.style.getPropertyValue("--max-height").replace("px", ""));
16 if (!isNaN(currentMaxHeight)) {
17 const newMaxHeight = currentMaxHeight - heightDiff;
18 nav.style.setProperty("--max-height", `${newMaxHeight}px`);
19 }
20 prevWindowHeight = windowHeight;
21});