Fix bug with collapsible grids inside of group widget
Also move utils to new file
This commit is contained in:
parent
d5fa6424c1
commit
b0c4d70628
2 changed files with 33 additions and 29 deletions
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue