Merge pull request #10534 from thot-experiment/dev
rewrite uiElementIsVisible
This commit is contained in:
commit
fe7bcbe340
5
javascript/dragdrop.js
vendored
5
javascript/dragdrop.js
vendored
@ -81,7 +81,10 @@ window.addEventListener('paste', e => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const visibleImageFields = [...gradioApp().querySelectorAll('[data-testid="image"]')]
|
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) {
|
if (!visibleImageFields.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
28
script.js
28
script.js
@ -92,19 +92,21 @@ document.addEventListener('keydown', function(e) {
|
|||||||
* checks that a UI element is not in another hidden element or tab content
|
* checks that a UI element is not in another hidden element or tab content
|
||||||
*/
|
*/
|
||||||
function uiElementIsVisible(el) {
|
function uiElementIsVisible(el) {
|
||||||
let isVisible = !el.closest('.\\!hidden');
|
if (el === document) {
|
||||||
if (!isVisible) {
|
return true;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while ((isVisible = el.closest('.tabitem')?.style.display) !== 'none') {
|
const computedStyle = getComputedStyle(el);
|
||||||
if (!isVisible) {
|
const isVisible = computedStyle.display !== 'none';
|
||||||
return false;
|
|
||||||
} else if (el.parentElement) {
|
if (!isVisible) return false;
|
||||||
el = el.parentElement;
|
return uiElementIsVisible(el.parentNode);
|
||||||
} else {
|
}
|
||||||
break;
|
|
||||||
}
|
function uiElementInSight(el) {
|
||||||
}
|
const clRect = el.getBoundingClientRect();
|
||||||
return isVisible;
|
const windowHeight = window.innerHeight;
|
||||||
|
const isOnScreen = clRect.bottom > 0 && clRect.top < windowHeight;
|
||||||
|
|
||||||
|
return isOnScreen;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user