This commit is contained in:
2023-08-11 10:45:20 +08:00
commit 161ca982f3
31850 changed files with 2706500 additions and 0 deletions

41
node_modules/vant/es/tabs/utils.js generated vendored Normal file
View File

@ -0,0 +1,41 @@
import { raf } from '../utils/dom/raf';
import { getScrollTop, setScrollTop } from '../utils/dom/scroll';
export function scrollLeftTo(scroller, to, duration) {
var count = 0;
var from = scroller.scrollLeft;
var frames = duration === 0 ? 1 : Math.round(duration * 1000 / 16);
function animate() {
scroller.scrollLeft += (to - from) / frames;
if (++count < frames) {
raf(animate);
}
}
animate();
}
export function scrollTopTo(scroller, to, duration, callback) {
var current = getScrollTop(scroller);
var isDown = current < to;
var frames = duration === 0 ? 1 : Math.round(duration * 1000 / 16);
var step = (to - current) / frames;
function animate() {
current += step;
if (isDown && current > to || !isDown && current < to) {
current = to;
}
setScrollTop(scroller, current);
if (isDown && current < to || !isDown && current > to) {
raf(animate);
} else if (callback) {
raf(callback);
}
}
animate();
}