mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-01-16 03:23:59 +01:00
Optimized for mobile
This commit is contained in:
parent
d1bbecd71b
commit
120465b46a
@ -70,6 +70,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isSmallScreen() {
|
||||||
|
return window.innerWidth < 992; // Bootstrap-Breakpoint für 'lg'
|
||||||
|
}
|
||||||
|
|
||||||
function adjustMenuPosition(submenu, parent, isTopLevel) {
|
function adjustMenuPosition(submenu, parent, isTopLevel) {
|
||||||
const rect = submenu.getBoundingClientRect();
|
const rect = submenu.getBoundingClientRect();
|
||||||
const parentRect = parent.getBoundingClientRect();
|
const parentRect = parent.getBoundingClientRect();
|
||||||
@ -85,8 +89,13 @@ function adjustMenuPosition(submenu, parent, isTopLevel) {
|
|||||||
submenu.style.right = '';
|
submenu.style.right = '';
|
||||||
|
|
||||||
if (isTopLevel) {
|
if (isTopLevel) {
|
||||||
|
if (isSmallScreen && spaceBelow < spaceAbove) {
|
||||||
|
// Für kleine Bildschirme: Menü direkt über dem Eltern-Element öffnen
|
||||||
|
submenu.style.top = 'auto';
|
||||||
|
submenu.style.bottom = `${parentRect.height}px`; // Direkt über dem Eltern-Element
|
||||||
|
}
|
||||||
// Top-Level-Menü
|
// Top-Level-Menü
|
||||||
if (spaceBelow < spaceAbove) {
|
else if (spaceBelow < spaceAbove) {
|
||||||
submenu.style.bottom = `${window.innerHeight - parentRect.bottom - parentRect.height}px`;
|
submenu.style.bottom = `${window.innerHeight - parentRect.bottom - parentRect.height}px`;
|
||||||
submenu.style.top = 'auto';
|
submenu.style.top = 'auto';
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user