From 1c99341c09f0318260ae467ad9d4d391acbfd3f6 Mon Sep 17 00:00:00 2001 From: Xuew <1914226339@qq.com> Date: Wed, 23 Nov 2022 00:36:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DpageScrollTo=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=9C=A8h5=E4=B8=8B=E5=8F=AF=E8=83=BD=E9=80=A0?= =?UTF-8?q?=E6=88=90=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98(#285)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/packages/interactive/pageScrollTo/src/web/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/packages/interactive/pageScrollTo/src/web/index.ts b/src/packages/interactive/pageScrollTo/src/web/index.ts index 1375aa64..412161b6 100644 --- a/src/packages/interactive/pageScrollTo/src/web/index.ts +++ b/src/packages/interactive/pageScrollTo/src/web/index.ts @@ -51,6 +51,8 @@ export default normalize((options: Options) => { // Scroll distance per 1ms const speed = (scrollTop - top) / duration; + let nextTop = top; + const handleScroll = (startTime: number) => { requestAnimationFrame(() => { const cost = Date.now() - startTime; @@ -59,8 +61,7 @@ export default normalize((options: Options) => { return; } - top = rootElement.scrollTop; - let nextTop = top + cost * speed; + nextTop = nextTop + cost * speed; if ((speed > 0 && nextTop > scrollTop) || (speed < 0 && nextTop < scrollTop)) { nextTop = scrollTop; }