From b8af58d8d0590c00a625c5018bb67086a4a3c8ff Mon Sep 17 00:00:00 2001 From: Maaxxs <61059039+MaaxxsDev@users.noreply.github.com> Date: Mon, 6 Jul 2026 17:48:34 +0200 Subject: [PATCH] Fix broken menu fade-in and left-align the fullscreen menu The single requestAnimationFrame used to trigger the fade-in was unreliable - the browser could coalesce the hidden and visible states into one paint, so items appeared instantly instead of fading/flying in. Switched to a double-rAF, which reliably guarantees a paint of the hidden state first. Also moves the menu content and close button to the left side per feedback. Co-Authored-By: Claude Sonnet 5 --- hifi-src/src/components/Navbar.jsx | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/hifi-src/src/components/Navbar.jsx b/hifi-src/src/components/Navbar.jsx index d13883e..6f19163 100644 --- a/hifi-src/src/components/Navbar.jsx +++ b/hifi-src/src/components/Navbar.jsx @@ -25,8 +25,18 @@ export default function Navbar() { useEffect(() => { if (open) { setMounted(true); - const id = requestAnimationFrame(() => setMenuVisible(true)); - return () => cancelAnimationFrame(id); + // Doppeltes rAF: nach dem Mounten braucht der Browser einen echten Paint mit der + // "versteckten" Ausgangsposition, bevor wir auf "sichtbar" umschalten - sonst + // fasst er beide Zustandsänderungen in einem Frame zusammen und es gibt keinen + // sichtbaren Übergang (kein Fade-in). + let rafInner; + const rafOuter = requestAnimationFrame(() => { + rafInner = requestAnimationFrame(() => setMenuVisible(true)); + }); + return () => { + cancelAnimationFrame(rafOuter); + if (rafInner) cancelAnimationFrame(rafInner); + }; } setMenuVisible(false); const closeDuration = FLY_DURATION_MS + (totalItems - 1) * ITEM_DELAY_MS; @@ -110,18 +120,18 @@ export default function Navbar() { {mounted && createPortal(
setOpen(false)} className={`text-3xl font-extrabold tracking-tight text-neutral-900 hover:text-brand-600 ${flyIn()}`} style={flyInStyle(0)}> @@ -141,8 +151,8 @@ export default function Navbar() { {phone && ( - {phone} + {phone} )} {whatsapp && ( @@ -153,8 +163,8 @@ export default function Navbar() { className={`flex items-center gap-2 text-sm font-semibold uppercase tracking-wide text-neutral-600 hover:text-brand-600 ${flyIn()}`} style={flyInStyle(6)} > - WhatsApp + WhatsApp )} - Zum Shop + Zum Shop
, document.body