mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-25 23:03:36 +01:00
35 lines
627 B
JavaScript
Vendored
35 lines
627 B
JavaScript
Vendored
var rafSchd = function rafSchd(fn) {
|
|
var lastArgs = [];
|
|
var frameId = null;
|
|
|
|
var wrapperFn = function wrapperFn() {
|
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
args[_key] = arguments[_key];
|
|
}
|
|
|
|
lastArgs = args;
|
|
|
|
if (frameId) {
|
|
return;
|
|
}
|
|
|
|
frameId = requestAnimationFrame(function () {
|
|
frameId = null;
|
|
fn.apply(void 0, lastArgs);
|
|
});
|
|
};
|
|
|
|
wrapperFn.cancel = function () {
|
|
if (!frameId) {
|
|
return;
|
|
}
|
|
|
|
cancelAnimationFrame(frameId);
|
|
frameId = null;
|
|
};
|
|
|
|
return wrapperFn;
|
|
};
|
|
|
|
export default rafSchd;
|