Browse Source

fix: 🐛

imwald
codytseng 7 months ago
parent
commit
4f8d6a0a11
  1. 14
      src/layouts/PrimaryPageLayout/index.tsx

14
src/layouts/PrimaryPageLayout/index.tsx

@ -45,12 +45,19 @@ const PrimaryPageLayout = forwardRef( @@ -45,12 +45,19 @@ const PrimaryPageLayout = forwardRef(
)
useEffect(() => {
if (isSmallScreen) {
if (smallScreenScrollAreaRef.current?.checkVisibility()) {
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 (smallScreenScrollAreaRef.current?.checkVisibility()) {
if (isVisible()) {
smallScreenLastScrollTopRef.current = window.scrollY
}
}
@ -58,7 +65,6 @@ const PrimaryPageLayout = forwardRef( @@ -58,7 +65,6 @@ const PrimaryPageLayout = forwardRef(
return () => {
window.removeEventListener('scroll', handleScroll)
}
}
}, [current, isSmallScreen, display])
if (isSmallScreen) {

Loading…
Cancel
Save