mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
[improvement] rename packages dir to src (#3659)
This commit is contained in:
17
src/tabs/utils.ts
Normal file
17
src/tabs/utils.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { raf } from '../utils/dom/raf';
|
||||
|
||||
export function scrollLeftTo(el: HTMLElement, to: number, duration: number) {
|
||||
let count = 0;
|
||||
const from = el.scrollLeft;
|
||||
const frames = duration === 0 ? 1 : Math.round((duration * 1000) / 16);
|
||||
|
||||
function animate() {
|
||||
el.scrollLeft += (to - from) / frames;
|
||||
|
||||
if (++count < frames) {
|
||||
raf(animate);
|
||||
}
|
||||
}
|
||||
|
||||
animate();
|
||||
}
|
Reference in New Issue
Block a user