mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-29 19:05:05 +08:00
rewrite uiElementIsVisible
rewrite visibility checking to be more generic/cleaner as well as add functionality to check if the element is scrolled on screen for more intuitive paste-target selection
This commit is contained in:
parent
a375acdd26
commit
e373fd0c00
24
script.js
24
script.js
@ -92,19 +92,17 @@ document.addEventListener('keydown', function(e) {
|
||||
* 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;
|
||||
if (el === document) {
|
||||
return true;
|
||||
}
|
||||
|
||||
while ((isVisible = el.closest('.tabitem')?.style.display) !== 'none') {
|
||||
if (!isVisible) {
|
||||
return false;
|
||||
} else if (el.parentElement) {
|
||||
el = el.parentElement;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isVisible;
|
||||
const computedStyle = getComputedStyle(el);
|
||||
const isVisible = computedStyle.display !== 'none';
|
||||
|
||||
const clRect = el.getBoundingClientRect();
|
||||
const windowHeight = window.innerHeight;
|
||||
const onScreen = clRect.bottom > 0 && clRect.top < windowHeight;
|
||||
|
||||
if (!isVisible || !onScreen) return false;
|
||||
return uiElementIsVisible(el.parentNode);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user