WebUI: implement debounce behavior for resize events

This commit is contained in:
Chocobo1 2024-08-09 17:48:03 +08:00
parent 0c580c3174
commit 29379232aa
No known key found for this signature in database
GPG key ID: 210D9C873253A68C
6 changed files with 43 additions and 31 deletions

View file

@ -119,14 +119,9 @@ window.qBittorrent.DynamicTable ??= (() => {
}
};
this.resizeDebounceTimer = -1;
const resizeDebouncer = (entries) => {
clearTimeout(this.resizeDebounceTimer);
this.resizeDebounceTimer = setTimeout(() => {
resizeFn(entries);
this.resizeDebounceTimer = -1;
}, 100);
};
const resizeDebouncer = window.qBittorrent.Misc.createDebounceHandler(100, (entries) => {
resizeFn(entries);
});
const resizeObserver = new ResizeObserver(resizeDebouncer);
resizeObserver.observe(parentPanel, { box: "border-box" });