aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--javascript/dragdrop.js5
-rw-r--r--script.js10
2 files changed, 11 insertions, 4 deletions
diff --git a/javascript/dragdrop.js b/javascript/dragdrop.js
index e316a365..398a33f9 100644
--- a/javascript/dragdrop.js
+++ b/javascript/dragdrop.js
@@ -81,7 +81,10 @@ window.addEventListener('paste', e => {
}
const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')]
- .filter(el => uiElementIsVisible(el));
+ .filter(el => uiElementIsVisible(el))
+ .sort((a,b) => uiElementInSight(b) - uiElementInSight(a));
+
+
if (!visibleImageFields.length) {
return;
}
diff --git a/script.js b/script.js
index 53390be3..f7612779 100644
--- a/script.js
+++ b/script.js
@@ -99,10 +99,14 @@ function uiElementIsVisible(el) {
const computedStyle = getComputedStyle(el);
const isVisible = computedStyle.display !== 'none';
+ if (!isVisible) return false;
+ return uiElementIsVisible(el.parentNode);
+}
+
+function uiElementInSight(el) {
const clRect = el.getBoundingClientRect();
const windowHeight = window.innerHeight;
- const onScreen = clRect.bottom > 0 && clRect.top < windowHeight;
+ const isOnScreen = clRect.bottom > 0 && clRect.top < windowHeight;
- if (!isVisible || !onScreen) return false;
- return uiElementIsVisible(el.parentNode);
+ return isOnScreen;
}