From 66fd3daf216c34ecba8a7d70374f467581f7c8a8 Mon Sep 17 00:00:00 2001 From: xangelo Date: Wed, 25 Jan 2023 13:52:28 -0500 Subject: [PATCH] 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. --- public/assets/bundle.js | 2 +- src/dom.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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) ); } -- 2.25.1