Files
video-gen/video-gen-admin/node_modules/antd/es/_util/throttleByAnimationFrame.js
T
2026-05-25 17:08:18 +08:00

20 lines
552 B
JavaScript

import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import raf from "@rc-component/util/es/raf";
function throttleByAnimationFrame(fn) {
let requestId = null;
const later = args => () => {
requestId = null;
fn.apply(void 0, _toConsumableArray(args));
};
const throttled = (...args) => {
if (requestId === null) {
requestId = raf(later(args));
}
};
throttled.cancel = () => {
raf.cancel(requestId);
requestId = null;
};
return throttled;
}
export default throttleByAnimationFrame;