From 38b1be3ac2e19b7cab1e71fa31f3a98cbb8f6b93 Mon Sep 17 00:00:00 2001 From: neverland <chenjiahan@youzan.com> Date: Wed, 22 Sep 2021 16:03:22 +0800 Subject: [PATCH] fix(Tabs): failed to scroll into view when rendering multiple tabs (#9543) --- packages/vant/src/tabs/utils.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/packages/vant/src/tabs/utils.ts b/packages/vant/src/tabs/utils.ts index aaee7e228..a1d7fea53 100644 --- a/packages/vant/src/tabs/utils.ts +++ b/packages/vant/src/tabs/utils.ts @@ -1,15 +1,11 @@ -import { raf, cancelRaf } from '@vant/use'; +import { raf } from '@vant/use'; import { ScrollElement, getScrollTop, setScrollTop } from '../utils'; -let rafId: number; - export function scrollLeftTo( scroller: HTMLElement, to: number, duration: number ) { - cancelRaf(rafId); - let count = 0; const from = scroller.scrollLeft; const frames = duration === 0 ? 1 : Math.round((duration * 1000) / 16); @@ -18,7 +14,7 @@ export function scrollLeftTo( scroller.scrollLeft += (to - from) / frames; if (++count < frames) { - rafId = raf(animate); + raf(animate); } }