refactor: improve code maintainability

This commit is contained in:
Erzbir
2026-06-15 22:06:13 +08:00
parent 72346d78d2
commit fdec0aafa1
12 changed files with 421 additions and 291 deletions
+13
View File
@@ -0,0 +1,13 @@
export function debounce(callback, wait = 250) {
let timeoutId;
return (...args) => {
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => callback(...args), wait);
};
}
export function toggleClass(element, className, enabled) {
if (!element) return;
element.classList.toggle(className, enabled);
}