authored and GitHub committed 2023-05-10 15:50:58 +00:00
1 parent 54f399c4df
commit 23ae939ef3
8 files changed
+111 -39

No files matched your search

+13
View File
@@ -1,3 +1,5 @@
import {debounce} from 'throttle-debounce';
function elementsCall(el, func, ...args) {
if (typeof el === 'string' || el instanceof String) {
el = document.querySelectorAll(el);
@@ -42,6 +44,13 @@ export function toggleElem(el, force) {
elementsCall(el, toggleShown, force);
}
export function isElemHidden(el) {
const res = [];
elementsCall(el, (e) => res.push(e.classList.contains('gt-hidden')));
if (res.length > 1) throw new Error(`isElemHidden doesn't work for multiple elements`);
return res[0];
}
export function onDomReady(cb) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', cb);
@@ -170,3 +179,7 @@ export function autosize(textarea, {viewportMarginBottom = 0} = {}) {
}
};
}
export function onInputDebounce(fn) {
return debounce(300, fn);
}