Fix: Karte-Höhe via JS, events Leaflet-Pfad, Hamburger-Menü mobile Drawer
This commit is contained in:
parent
0438bd6bfe
commit
d4c3f159d5
6 changed files with 107 additions and 3 deletions
|
|
@ -150,11 +150,30 @@ const App = (() => {
|
|||
// + Button (Mobile Bottom-Nav + Desktop Sidebar)
|
||||
if (e.target.closest('#nav-add') || e.target.closest('#sidebar-add')) {
|
||||
_showQuickAdd();
|
||||
return;
|
||||
}
|
||||
|
||||
// Hamburger-Menü (Mobile)
|
||||
if (e.target.closest('#header-menu-btn')) {
|
||||
_toggleSidebar();
|
||||
return;
|
||||
}
|
||||
|
||||
// Backdrop → Sidebar schließen
|
||||
if (e.target.closest('#sidebar-backdrop')) {
|
||||
_closeSidebar();
|
||||
return;
|
||||
}
|
||||
|
||||
// Sidebar-Item auf Mobile → schließen nach Navigation
|
||||
if (e.target.closest('#sidebar .sidebar-item')) {
|
||||
_closeSidebar();
|
||||
}
|
||||
});
|
||||
|
||||
// Browser Back/Forward
|
||||
window.addEventListener('popstate', e => {
|
||||
_closeSidebar();
|
||||
const page = e.state?.page || 'diary';
|
||||
navigate(page, false);
|
||||
});
|
||||
|
|
@ -163,6 +182,26 @@ const App = (() => {
|
|||
// damit kein doppelter _loadPage()-Aufruf entsteht.
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// MOBILE SIDEBAR DRAWER
|
||||
// ----------------------------------------------------------
|
||||
function _toggleSidebar() {
|
||||
const sidebar = document.getElementById('sidebar');
|
||||
const backdrop = document.getElementById('sidebar-backdrop');
|
||||
const isOpen = sidebar?.classList.contains('open');
|
||||
isOpen ? _closeSidebar() : _openSidebar();
|
||||
}
|
||||
|
||||
function _openSidebar() {
|
||||
document.getElementById('sidebar')?.classList.add('open');
|
||||
document.getElementById('sidebar-backdrop')?.classList.add('visible');
|
||||
}
|
||||
|
||||
function _closeSidebar() {
|
||||
document.getElementById('sidebar')?.classList.remove('open');
|
||||
document.getElementById('sidebar-backdrop')?.classList.remove('visible');
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// SCHNELL-HINZUFÜGEN (+ Button)
|
||||
// ----------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -201,10 +201,10 @@ window.Page_events = (() => {
|
|||
return new Promise((resolve, reject) => {
|
||||
const link = document.createElement('link');
|
||||
link.rel = 'stylesheet';
|
||||
link.href = '/js/lib/leaflet.css';
|
||||
link.href = '/css/leaflet.css';
|
||||
document.head.appendChild(link);
|
||||
const s = document.createElement('script');
|
||||
s.src = '/js/lib/leaflet.js';
|
||||
s.src = '/js/leaflet.js';
|
||||
s.onload = resolve;
|
||||
s.onerror = reject;
|
||||
document.head.appendChild(s);
|
||||
|
|
|
|||
|
|
@ -129,6 +129,19 @@ window.Page_map = (() => {
|
|||
const el = document.getElementById('central-map');
|
||||
if (!el || !window.L || _map) return;
|
||||
|
||||
// Explizite Pixel-Höhe setzen, damit Leaflet Kacheln lädt.
|
||||
// height:100% auf einem flex:1-Child ohne feste Parent-Höhe = 0px.
|
||||
const layout = el.closest('.map-full-layout');
|
||||
if (layout) {
|
||||
const top = layout.getBoundingClientRect().top;
|
||||
layout.style.height = (window.innerHeight - top) + 'px';
|
||||
window.addEventListener('resize', () => {
|
||||
const t = layout.getBoundingClientRect().top;
|
||||
layout.style.height = (window.innerHeight - t) + 'px';
|
||||
_map?.invalidateSize();
|
||||
});
|
||||
}
|
||||
|
||||
const center = _userPos ? [_userPos.lat, _userPos.lon] : [51.1657, 10.4515];
|
||||
const zoom = _userPos ? 13 : 6;
|
||||
|
||||
|
|
@ -137,6 +150,8 @@ window.Page_map = (() => {
|
|||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { maxZoom: 19 })
|
||||
.addTo(_map);
|
||||
|
||||
setTimeout(() => _map.invalidateSize(), 100);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue