@amcharts/amcharts5
Version:
amCharts 5
24 lines • 584 B
JavaScript
export class Throttler {
constructor(fn) {
this._ready = true;
this._pending = false;
this._fn = fn;
}
run() {
if (this._ready) {
this._ready = false;
this._pending = false;
requestAnimationFrame(() => {
this._ready = true;
if (this._pending) {
this.run();
}
});
this._fn();
}
else {
this._pending = true;
}
}
}
//# sourceMappingURL=Throttler.js.map