优化内存泄露的问题
This commit is contained in:
@@ -111,3 +111,17 @@ function animateValue(element, start, end, duration = 600) {
|
||||
|
||||
requestAnimationFrame(update);
|
||||
}
|
||||
|
||||
/**
|
||||
* Debounce function to limit execution frequency
|
||||
*/
|
||||
function debounce(fn, delay) {
|
||||
let timer = null;
|
||||
return function (...args) {
|
||||
if (timer) clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
fn.apply(this, args);
|
||||
timer = null;
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user