| 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`); |
| Davit Tabidze | 56bcf25 | 2024-06-12 19:00:45 +0400 | [diff] [blame^] | 7 | 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 Tabidze | 014c696 | 2024-06-07 18:37:04 +0400 | [diff] [blame] | 10 | }); |
| 11 | |
| 12 | let prevWindowHeight = window.innerHeight; |
| 13 | |
| 14 | window.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 | }); |