dvant
Version:
A Vue.js 2.0 Mobile UI at dawnwin modified from Youzan
39 lines (29 loc) • 790 B
JavaScript
;
exports.__esModule = true;
exports.raf = raf;
exports.cancel = cancel;
var _index = require('./index');
var prev = Date.now();
/* istanbul ignore next */
/**
* requestAnimationFrame polyfill
*/
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 = _index.isServer ? global : window;
/* istanbul ignore next */
var iRaf = root.requestAnimationFrame || root.webkitRequestAnimationFrame || fallback;
/* istanbul ignore next */
var iCancel = root.cancelAnimationFrame || root.webkitCancelAnimationFrame || root.clearTimeout;
function raf(fn) {
return iRaf.call(root, fn);
}
function cancel(id) {
iCancel.call(root, id);
}