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
|
* 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) {
|
const clRect = el.getBoundingClientRect();
|
||||||
el = el.parentElement;
|
const windowHeight = window.innerHeight;
|
||||||
} else {
|
const onScreen = clRect.bottom > 0 && clRect.top < windowHeight;
|
||||||
break;
|
|
||||||
}
|
if (!isVisible || !onScreen) return false;
|
||||||
}
|
return uiElementIsVisible(el.parentNode);
|
||||||
return isVisible;
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user