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

50
node_modules/vant/lib/tabs/utils.js generated vendored Normal file
View File

@ -0,0 +1,50 @@
"use strict";
exports.__esModule = true;
exports.scrollLeftTo = scrollLeftTo;
exports.scrollTopTo = scrollTopTo;
var _raf = require("../utils/dom/raf");
var _scroll = require("../utils/dom/scroll");
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) {
(0, _raf.raf)(animate);
}
}
animate();
}
function scrollTopTo(scroller, to, duration, callback) {
var current = (0, _scroll.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;
}
(0, _scroll.setScrollTop)(scroller, current);
if (isDown && current < to || !isDown && current > to) {
(0, _raf.raf)(animate);
} else if (callback) {
(0, _raf.raf)(callback);
}
}
animate();
}