fix: 🐛

This commit is contained in:
codytseng
2025-08-31 12:05:11 +08:00
parent b995e2150b
commit 4f8d6a0a11

View File

@@ -45,20 +45,26 @@ const PrimaryPageLayout = forwardRef(
)
useEffect(() => {
if (isSmallScreen) {
if (smallScreenScrollAreaRef.current?.checkVisibility()) {
window.scrollTo({ top: smallScreenLastScrollTopRef.current, behavior: 'instant' })
}
const handleScroll = () => {
if (smallScreenScrollAreaRef.current?.checkVisibility()) {
smallScreenLastScrollTopRef.current = window.scrollY
}
}
window.addEventListener('scroll', handleScroll)
return () => {
window.removeEventListener('scroll', handleScroll)
if (!isSmallScreen) return
const isVisible = () => {
return smallScreenScrollAreaRef.current?.checkVisibility
? smallScreenScrollAreaRef.current?.checkVisibility()
: false
}
if (isVisible()) {
window.scrollTo({ top: smallScreenLastScrollTopRef.current, behavior: 'instant' })
}
const handleScroll = () => {
if (isVisible()) {
smallScreenLastScrollTopRef.current = window.scrollY
}
}
window.addEventListener('scroll', handleScroll)
return () => {
window.removeEventListener('scroll', handleScroll)
}
}, [current, isSmallScreen, display])
if (isSmallScreen) {