mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-02 13:48:05 -06:00
WebUI: implement debounce behavior for resize events
This commit is contained in:
@@ -32,6 +32,7 @@ window.qBittorrent ??= {};
|
||||
window.qBittorrent.Misc ??= (() => {
|
||||
const exports = () => {
|
||||
return {
|
||||
createDebounceHandler: createDebounceHandler,
|
||||
friendlyUnit: friendlyUnit,
|
||||
friendlyDuration: friendlyDuration,
|
||||
friendlyPercentage: friendlyPercentage,
|
||||
@@ -50,6 +51,18 @@ window.qBittorrent.Misc ??= (() => {
|
||||
};
|
||||
};
|
||||
|
||||
const createDebounceHandler = (delay, func) => {
|
||||
let timer = -1;
|
||||
return (...params) => {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(() => {
|
||||
func(...params);
|
||||
|
||||
timer = -1;
|
||||
}, delay);
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
* JS counterpart of the function in src/misc.cpp
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user