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

36
node_modules/vant/es/utils/dom/raf.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
/**
* requestAnimationFrame polyfill
*/
import { isServer } from '..';
var prev = Date.now();
/* istanbul ignore next */
function fallback(fn) {
var curr = Date.now();
var ms = Math.max(0, 16 - (curr - prev));
var id = setTimeout(fn, ms);
prev = curr + ms;
return id;
}
/* istanbul ignore next */
var root = isServer ? global : window;
/* istanbul ignore next */
var iRaf = root.requestAnimationFrame || fallback;
/* istanbul ignore next */
var iCancel = root.cancelAnimationFrame || root.clearTimeout;
export function raf(fn) {
return iRaf.call(root, fn);
} // double raf for animation
export function doubleRaf(fn) {
raf(function () {
raf(fn);
});
}
export function cancelRaf(id) {
iCancel.call(root, id);
}