Update utils.js

This commit is contained in:
N-Pex 2021-03-04 13:11:17 +01:00
parent 902fa3a171
commit e9098123b4

View file

@ -384,11 +384,13 @@ class Util {
} }
isChildVisible(parentNode, childNode) { isChildVisible(parentNode, childNode) {
let top = parentNode.scrollTop; const rect1 = parentNode.getBoundingClientRect();
let bottom = top + parentNode.clientHeight; const rect2 = childNode.getBoundingClientRect();
const childTop = childNode.offsetTop; var overlap = !(rect1.right < rect2.left ||
const childBottom = childTop + childNode.clientHeight; rect1.left > rect2.right ||
return ((childTop >= top && childTop < bottom) || (childBottom > top && childBottom <= bottom)); rect1.bottom < rect2.top ||
rect1.top > rect2.bottom)
return overlap;
} }
findOneVisibleElement(parentNode) { findOneVisibleElement(parentNode) {