mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-01-15 19:23:58 +01:00
Optimized menu bug. now distance from main menu to submenu of 1 item exist
This commit is contained in:
parent
00e0096f8a
commit
f9d5a90f94
@ -99,7 +99,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
if (isTopLevel) {
|
if (isTopLevel) {
|
||||||
// Top-Level-Menüs öffnen nur nach oben oder unten
|
// Top-Level-Menüs öffnen nur nach oben oder unten
|
||||||
if (spaceBelow < rect.height && spaceAbove > rect.height) {
|
if (spaceBelow < rect.height && spaceAbove > rect.height) {
|
||||||
submenu.style.bottom = '100%';
|
submenu.style.bottom = `${window.innerHeight - parentRect.bottom}px`;
|
||||||
submenu.style.top = 'auto';
|
submenu.style.top = 'auto';
|
||||||
} else {
|
} else {
|
||||||
submenu.style.top = `${parentRect.height}px`;
|
submenu.style.top = `${parentRect.height}px`;
|
||||||
@ -111,9 +111,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
submenu.style.left = prefersRight ? '100%' : 'auto';
|
submenu.style.left = prefersRight ? '100%' : 'auto';
|
||||||
submenu.style.right = prefersRight ? 'auto' : '100%';
|
submenu.style.right = prefersRight ? 'auto' : '100%';
|
||||||
|
|
||||||
const prefersBelow = spaceBelow >= spaceAbove;
|
// Öffnen nach oben, wenn unten kein Platz ist
|
||||||
submenu.style.top = prefersBelow ? '0' : 'auto';
|
if (spaceBelow < rect.height && spaceAbove > rect.height) {
|
||||||
submenu.style.bottom = prefersBelow ? 'auto' : '100%';
|
submenu.style.top = 'auto';
|
||||||
|
submenu.style.bottom = `${parentRect.bottom - parentRect.top}px`;
|
||||||
|
} else {
|
||||||
|
submenu.style.top = '0';
|
||||||
|
submenu.style.bottom = 'auto';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user