fix: ensure titlebar appears when scrolling to top on mobile

This commit is contained in:
codytseng
2024-12-08 15:25:08 +08:00
parent d6f5a67004
commit 49a9824034
2 changed files with 18 additions and 6 deletions

View File

@@ -32,13 +32,18 @@ const PrimaryPageLayout = forwardRef(({ children }: { children?: React.ReactNode
const handleScroll = () => {
const scrollTop = scrollAreaRef.current?.scrollTop || 0
const diff = scrollTop - lastScrollTop
if (diff > 50) {
setVisible(false)
setLastScrollTop(scrollTop)
} else if (diff < -50) {
if (scrollTop <= 100) {
setVisible(true)
setLastScrollTop(scrollTop)
return
}
if (diff > 50) {
setVisible(false)
} else if (diff < -50) {
setVisible(true)
}
setLastScrollTop(scrollTop)
}
const scrollArea = scrollAreaRef.current

View File

@@ -26,9 +26,16 @@ export default function SecondaryPageLayout({
useEffect(() => {
const handleScroll = () => {
const scrollTop = scrollAreaRef.current?.scrollTop || 0
if (scrollTop > lastScrollTop) {
const diff = scrollTop - lastScrollTop
if (scrollTop <= 100) {
setVisible(true)
setLastScrollTop(scrollTop)
return
}
if (diff > 50) {
setVisible(false)
} else {
} else if (diff < -50) {
setVisible(true)
}
setLastScrollTop(scrollTop)