From f04b7050723393c5ea546ea6c914beac808d11c6 Mon Sep 17 00:00:00 2001 From: marzban-dev Date: Mon, 27 Oct 2025 12:34:25 +0330 Subject: [PATCH] Fix mega menu animation and style --- frontend/components/global/MegaMenu.vue | 148 +++++++++++++++++------- 1 file changed, 105 insertions(+), 43 deletions(-) diff --git a/frontend/components/global/MegaMenu.vue b/frontend/components/global/MegaMenu.vue index b428108..253f780 100644 --- a/frontend/components/global/MegaMenu.vue +++ b/frontend/components/global/MegaMenu.vue @@ -31,6 +31,14 @@ const isScrollLocked = useScrollLock(window); const navbarEl = ref(null); const { height: navbarHeight } = useElementSize(navbarEl); +const { $gsap: gsap } = useNuxtApp(); +let gsapTimeline: gsap.core.Timeline; + +const prevNavbarStyle = ref({ + itemFilter: "", + background: "", +}); + // computed const selectedItemSubItems = computed(() => { @@ -55,6 +63,14 @@ const menuTabMouseLeave = () => { selectTabTimer.value = null; }; +const updatePrevStyle = () => { + const headerNavbarEl = document.querySelector("#header-navbar")!; + const headerNavbarItemEl = document.querySelector(".header-navbar-item")!; + + prevNavbarStyle.value.background = getComputedStyle(headerNavbarEl).backgroundColor; + prevNavbarStyle.value.itemFilter = getComputedStyle(headerNavbarItemEl).filter; +}; + // watches watch( @@ -71,10 +87,54 @@ watch( } ); +watch(isOpen, async (newValue) => { + if (newValue) { + updatePrevStyle(); + + gsapTimeline + .to( + ".header-navbar-item", + { + filter: "invert(0%)", + } + ) + .to( + "#header-navbar", + { + background: "white", + }, + "=" + ); + } else { + gsapTimeline + .fromTo( + ".header-navbar-item", + { + filter: "invert(0%)", + }, + { + filter: prevNavbarStyle.value.itemFilter, + } + ) + .fromTo( + "#header-navbar", + { + background: "white", + }, + { + background: prevNavbarStyle.value.background, + }, + "=" + ); + } +}); + // lifecycle onMounted(() => { - navbarEl.value = document.querySelector("#header-navbar"); + gsapTimeline = gsap.timeline(); + + navbarEl.value = document.querySelector("#header-navbar"); }); @@ -86,51 +146,53 @@ onMounted(() => {
-
-
- -
-
- -
+
+
+
+
+ +
- - {{ item.title }} - - -
-
+ + + {{ item.title }} + + +
+ +