feat: 补充新项目hx-op

This commit is contained in:
xuziqiang
2024-06-07 15:11:04 +08:00
parent a0f5c4de08
commit fc940e7241
64 changed files with 28632 additions and 7 deletions

View File

@@ -0,0 +1,21 @@
export function debounce(_this: any, fn: (arg0: any) => void) {
// 用rAF去做防抖
return function (...args: any) {
if (_this.lock) return;
const run = function () {
// requestIdleCallback-任务调度
window.requestIdleCallback(function (deadline) {
_this.lock = true;
// 判断空闲时间
// 显示器刷新频率HZ 16.7ms内不会重复执行
if (deadline.timeRemaining() > 1000 / 60) {
fn(...args);
_this.lock = false;
} else {
run();
}
});
};
run();
};
}