From 7b61acbd35e9db43a5279a42afad3f3dc68462c9 Mon Sep 17 00:00:00 2001 From: Thottyottyotty Date: Thu, 18 May 2023 23:43:01 -0700 Subject: split visibility method and sort instead split out the visibility method for pasting and use a sort inside the paste handler to prioritize on-screen fields rather than targeting ONLY on screen fields --- script.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'script.js') 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; } -- cgit v1.2.3