From f9d5a90f94df97a105b13d5e9eab993deb4e98f6 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 14 Jan 2025 18:47:03 +0100 Subject: [PATCH] Optimized menu bug. now distance from main menu to submenu of 1 item exist --- app/static/js/navigation.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/static/js/navigation.js b/app/static/js/navigation.js index a9f7f65..017b167 100644 --- a/app/static/js/navigation.js +++ b/app/static/js/navigation.js @@ -99,7 +99,7 @@ document.addEventListener('DOMContentLoaded', () => { if (isTopLevel) { // Top-Level-Menüs öffnen nur nach oben oder unten if (spaceBelow < rect.height && spaceAbove > rect.height) { - submenu.style.bottom = '100%'; + submenu.style.bottom = `${window.innerHeight - parentRect.bottom}px`; submenu.style.top = 'auto'; } else { submenu.style.top = `${parentRect.height}px`; @@ -111,9 +111,14 @@ document.addEventListener('DOMContentLoaded', () => { submenu.style.left = prefersRight ? '100%' : 'auto'; submenu.style.right = prefersRight ? 'auto' : '100%'; - const prefersBelow = spaceBelow >= spaceAbove; - submenu.style.top = prefersBelow ? '0' : 'auto'; - submenu.style.bottom = prefersBelow ? 'auto' : '100%'; + // Öffnen nach oben, wenn unten kein Platz ist + if (spaceBelow < rect.height && spaceAbove > rect.height) { + submenu.style.top = 'auto'; + submenu.style.bottom = `${parentRect.bottom - parentRect.top}px`; + } else { + submenu.style.top = '0'; + submenu.style.bottom = 'auto'; + } } } });