From e9098123b4f45744a88e3ed3c69d0556c990350c Mon Sep 17 00:00:00 2001 From: N-Pex Date: Thu, 4 Mar 2021 13:11:17 +0100 Subject: [PATCH] Update utils.js --- src/plugins/utils.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/utils.js b/src/plugins/utils.js index 23ab97c..076354d 100644 --- a/src/plugins/utils.js +++ b/src/plugins/utils.js @@ -384,11 +384,13 @@ class Util { } isChildVisible(parentNode, childNode) { - let top = parentNode.scrollTop; - let bottom = top + parentNode.clientHeight; - const childTop = childNode.offsetTop; - const childBottom = childTop + childNode.clientHeight; - return ((childTop >= top && childTop < bottom) || (childBottom > top && childBottom <= bottom)); + const rect1 = parentNode.getBoundingClientRect(); + const rect2 = childNode.getBoundingClientRect(); + var overlap = !(rect1.right < rect2.left || + rect1.left > rect2.right || + rect1.bottom < rect2.top || + rect1.top > rect2.bottom) + return overlap; } findOneVisibleElement(parentNode) {