mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(Tabs): failed to scroll into view when render multiple tabs (#9542)
This commit is contained in:
parent
91d65d4a64
commit
cc2a40450e
@ -1,15 +1,11 @@
|
||||
import { raf, cancelRaf } from '../utils/dom/raf';
|
||||
import { raf } from '../utils/dom/raf';
|
||||
import { getScrollTop, setScrollTop } from '../utils/dom/scroll';
|
||||
|
||||
let scrollLeftRafId: number;
|
||||
|
||||
export function scrollLeftTo(
|
||||
scroller: HTMLElement,
|
||||
to: number,
|
||||
duration: number
|
||||
) {
|
||||
cancelRaf(scrollLeftRafId);
|
||||
|
||||
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) {
|
||||
scrollLeftRafId = raf(animate);
|
||||
raf(animate);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user