From a7f5063869f3c67cac6d847c27fb37406f6a2254 Mon Sep 17 00:00:00 2001 From: nineya <361654768@qq.com> Date: Thu, 14 Sep 2023 09:39:41 +0800 Subject: [PATCH] =?UTF-8?q?perf(pjax):=20=E4=BC=98=E5=8C=96pjax=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E6=97=B6=E9=A1=B6=E9=83=A8=E5=AF=BC=E8=88=AA=E6=94=B6?= =?UTF-8?q?=E7=BC=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/js/common.js | 6 +++--- src/js/pjax.js | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/js/common.js b/src/js/common.js index 08c2823..85ee560 100644 --- a/src/js/common.js +++ b/src/js/common.js @@ -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 } diff --git a/src/js/pjax.js b/src/js/pjax.js index 06622c2..abddb07 100644 --- a/src/js/pjax.js +++ b/src/js/pjax.js @@ -15,6 +15,8 @@ const initPjax = () => { const computeScrollTop = (target) => { // 当前为横幅大图模式,处理滚动 if (target.pathname !== '/' && $('.banner').length !== 0) { + // 避免跳转时顶部导航栏收缩 + window.initTop = 99999999 return window.innerHeight / 4 } return 0