winbox-ui-next
Version:
We Design Vue 2.0: A Vue.js 3 UI Library
23 lines (22 loc) • 478 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports[Symbol.toStringTag] = "Module";
var raf = require("./raf.js");
function throttleByRaf(cb) {
let timer = 0;
const throttle = (...args) => {
if (timer) {
raf.caf(timer);
}
timer = raf.raf(() => {
cb(...args);
timer = 0;
});
};
throttle.cancel = () => {
raf.caf(timer);
timer = 0;
};
return throttle;
}
exports.throttleByRaf = throttleByRaf;