perf(pjax): 优化pjax跳转时顶部导航收缩问题

This commit is contained in:
nineya 2023-09-14 09:39:41 +08:00
parent b3b94f73d3
commit a7f5063869
2 changed files with 5 additions and 3 deletions

View File

@ -139,12 +139,12 @@ const commonContext = {
},
/* 处理滚动 */
initScroll() {
let initTop = 0
window.initTop = 0
// true上划false下滑
function scrollDirection(currentTop) {
const result = currentTop > initTop
initTop = currentTop
const result = currentTop > window.initTop
window.initTop = currentTop
return result
}

View File

@ -15,6 +15,8 @@ const initPjax = () => {
const computeScrollTop = (target) => {
// 当前为横幅大图模式,处理滚动
if (target.pathname !== '/' && $('.banner').length !== 0) {
// 避免跳转时顶部导航栏收缩
window.initTop = 99999999
return window.innerHeight / 4
}
return 0