perf(custom): sppage锁定屏幕导致抖动问题

This commit is contained in:
chenxin
2025-08-06 14:07:41 +08:00
parent 8c36373fff
commit 57e1e48b2d

View File

@@ -85,18 +85,28 @@ const SpPage = memo(
useEffect(() => {
if (state.lock) {
// 保存当前滚动位置
const currentScrollTop = scrollTopRef.current || 0
setState((draft) => {
draft.lockStyle = {
position: 'fixed',
top: `-${scrollTopRef.current}px`,
left: '0px',
width: '100%',
bottom: '0px'
overflow: 'hidden'
}
})
// 设置滚动位置,防止回到顶部
setTimeout(() => {
Taro.pageScrollTo({
scrollTop: currentScrollTop,
duration: 0
})
}, 0)
} else {
setState((draft) => {
draft.lockStyle = {}
draft.lockStyle = {
overflow: 'auto'
}
})
}
}, [state.lock])
@@ -260,13 +270,6 @@ const SpPage = memo(
setState((draft) => {
draft.lock = false
})
setTimeout(() => {
Taro.pageScrollTo({
scrollTop: scrollTopRef.current,
duration: 0
})
}, 0)
}
}))
const computedNavigationStyle = () => {