aboutsummaryrefslogtreecommitdiff
path: root/script.js
diff options
context:
space:
mode:
Diffstat (limited to 'script.js')
-rw-r--r--script.js21
1 files changed, 21 insertions, 0 deletions
diff --git a/script.js b/script.js
index 7f26e23b..cf989605 100644
--- a/script.js
+++ b/script.js
@@ -39,3 +39,24 @@ document.addEventListener("DOMContentLoaded", function() {
});
mutationObserver.observe( gradioApp(), { childList:true, subtree:true })
});
+
+/**
+ * checks that a UI element is not in another hidden element or tab content
+ */
+function uiElementIsVisible(el) {
+ let isVisible = !el.closest('.\\!hidden');
+ if ( ! isVisible ) {
+ return false;
+ }
+
+ while( isVisible = el.closest('.tabitem')?.style.display !== 'none' ) {
+ if ( ! isVisible ) {
+ return false;
+ } else if ( el.parentElement ) {
+ el = el.parentElement
+ } else {
+ break;
+ }
+ }
+ return isVisible;
+} \ No newline at end of file