/**
 * @desc requestAnimationFrame 垫片
 */
var prev = Date.now();

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;
}

var root = window;
var iRaf = root.requestAnimationFrame || fallback;
var iCancel = root.cancelAnimationFrame || root.clearTimeout;
export function raf(fn) {
  return iRaf.call(root, fn);
}
export function cancel(id) {
  iCancel.call(root, id);
}