| Davit Tabidze | 014c696 | 2024-06-07 18:37:04 +0400 | [diff] [blame^] | 1 | document.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 | |
| 9 | let prevWindowHeight = window.innerHeight; |
| 10 | |
| 11 | window.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 | }); |