fix: ensure titlebar appears when scrolling to top on mobile
This commit is contained in:
parent
d6f5a67004
commit
49a9824034
2 changed files with 18 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue