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.
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;
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)
);
}