From dd1fd83045a6242360fd5d1e319ff35d746ce5d5 Mon Sep 17 00:00:00 2001 From: codytseng Date: Tue, 3 Dec 2024 23:01:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/layouts/PrimaryPageLayout/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/src/layouts/PrimaryPageLayout/index.tsx b/src/renderer/src/layouts/PrimaryPageLayout/index.tsx index a081b7e..30469df 100644 --- a/src/renderer/src/layouts/PrimaryPageLayout/index.tsx +++ b/src/renderer/src/layouts/PrimaryPageLayout/index.tsx @@ -30,12 +30,14 @@ const PrimaryPageLayout = forwardRef(({ children }: { children?: React.ReactNode useEffect(() => { const handleScroll = () => { const scrollTop = scrollAreaRef.current?.scrollTop || 0 - if (scrollTop > lastScrollTop) { + const diff = scrollTop - lastScrollTop + if (diff > 20) { setVisible(false) - } else { + setLastScrollTop(scrollTop) + } else if (diff < -20) { setVisible(true) + setLastScrollTop(scrollTop) } - setLastScrollTop(scrollTop) } const scrollArea = scrollAreaRef.current