mirror of
https://gitee.com/ShopeX/ECShopX_mobile-frontend
synced 2026-08-14 17:41:45 +08:00
perf(custom): sppage锁定屏幕导致抖动问题
This commit is contained in:
@@ -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 = () => {
|
||||
|
||||
Reference in New Issue
Block a user