From: xangelo Date: Wed, 25 Jan 2023 18:52:28 +0000 (-0500) Subject: bug: only account for if the top of an elemnet is out of view X-Git-Url: https://git.xangelo.ca/?p=apps%2Foutliner%2F.git;a=commitdiff_plain;h=66fd3daf216c34ecba8a7d70374f467581f7c8a8 bug: only account for if the top of an elemnet is out of view We were originally checking if the whole element was out of view, but due to the nested nature of things, this was always. Instead we only check to see if the top of the element is out of view. If it is, we scroll it into view otherwise we assume that enough of the node is visible for you. --- diff --git a/public/assets/bundle.js b/public/assets/bundle.js index ae072e4..e87375a 100644 --- a/public/assets/bundle.js +++ b/public/assets/bundle.js @@ -18690,7 +18690,7 @@ function isVisible(element) { const rect = element.getBoundingClientRect(); return (rect.top >= 0 && rect.left >= 0 && - rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth)); } exports.isVisible = isVisible; diff --git a/src/dom.ts b/src/dom.ts index 481c5ed..3ee623b 100644 --- a/src/dom.ts +++ b/src/dom.ts @@ -3,7 +3,7 @@ export function isVisible(element: HTMLElement): boolean { return ( rect.top >= 0 && rect.left >= 0 && - rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && + rect.top <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth) ); }