From 32a931eaea8ca7b59e65a6d07b5213625385cb4d Mon Sep 17 00:00:00 2001 From: xfy Date: Fri, 23 May 2025 02:38:52 +0800 Subject: [PATCH] fix(3d): animation error while switch page --- components/pages/nav-bar.tsx | 4 ++++ store/index.ts | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/components/pages/nav-bar.tsx b/components/pages/nav-bar.tsx index 144d3c8..3d8f095 100644 --- a/components/pages/nav-bar.tsx +++ b/components/pages/nav-bar.tsx @@ -52,7 +52,11 @@ const parentIdChecker = (el: HTMLElement | null): boolean => { const HeadBar = () => { const [showMenu, setShowMenu] = useState(false); + const resetNavbarHoverItems = useStore( + (state) => state.resetNavbarHoverItems, + ); const handleClick = () => { + resetNavbarHoverItems(); setShowMenu((showMenu) => !showMenu); }; diff --git a/store/index.ts b/store/index.ts index 1596e12..70f739f 100644 --- a/store/index.ts +++ b/store/index.ts @@ -16,6 +16,7 @@ interface MainStore { about: boolean; }; toggleNavbarHoverItems: (item: string) => void; + resetNavbarHoverItems: () => void; } const useStore = create()((set) => ({ @@ -41,6 +42,16 @@ const useStore = create()((set) => ({ !state.navbarHoverItems[item], }, })), + resetNavbarHoverItems: () => + set(() => ({ + navbarHoverItems: { + blog: false, + projects: false, + tags: false, + friends: false, + about: false, + }, + })), })); export default useStore;