mirror of
https://github.com/glanceapp/glance.git
synced 2025-08-09 15:54:58 +02:00
Fix bug with collapsible grids inside of group widget
Also move utils to new file
This commit is contained in:
25
internal/assets/static/js/utils.js
Normal file
25
internal/assets/static/js/utils.js
Normal file
@ -0,0 +1,25 @@
|
||||
export function throttledDebounce(callback, maxDebounceTimes, debounceDelay) {
|
||||
let debounceTimeout;
|
||||
let timesDebounced = 0;
|
||||
|
||||
return function () {
|
||||
if (timesDebounced == maxDebounceTimes) {
|
||||
clearTimeout(debounceTimeout);
|
||||
timesDebounced = 0;
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
clearTimeout(debounceTimeout);
|
||||
timesDebounced++;
|
||||
|
||||
debounceTimeout = setTimeout(() => {
|
||||
timesDebounced = 0;
|
||||
callback();
|
||||
}, debounceDelay);
|
||||
};
|
||||
};
|
||||
|
||||
export function isElementVisible(element) {
|
||||
return !!(element.offsetWidth || element.offsetHeight || element.getClientRects().length);
|
||||
}
|
Reference in New Issue
Block a user