mirror of
https://github.com/foo-dogsquared/website.git
synced 2025-01-31 16:58:03 +00:00
23 lines
561 B
JavaScript
23 lines
561 B
JavaScript
|
function toggleVisibilityEvent({event, target="", oneTime=false, callback} = {}) {
|
||
|
const element = event.target;
|
||
|
return toggleVisibility({element, target, oneTime, callback});
|
||
|
}
|
||
|
|
||
|
function toggleVisibility({element, target="", oneTime=false, callback} = {}) {
|
||
|
let exit = 0;
|
||
|
if (oneTime) {
|
||
|
element.classList.toggle("hidden");
|
||
|
}
|
||
|
|
||
|
if (target.length > 0) {
|
||
|
const targetElement = element.closest(target);
|
||
|
targetElement.classList.toggle("hidden");
|
||
|
}
|
||
|
|
||
|
if (callback) {
|
||
|
callback()
|
||
|
}
|
||
|
|
||
|
return exit;
|
||
|
}
|