const visible = (element) => {
let bounds = element.getBoundingClientRect();
- return bounds.top >= 0 && bounds.bottom <= window.innerHeight;
+ return Math.abs(bounds.bottom - bounds.top) > window.innerHeight || (bounds.top >= 0 && bounds.bottom <= window.innerHeight);
}
const changeWithVisibleCallback = (comment, callback) => {
const change = (comment) => {
elementsIndex = elements.indexOf(comment);
- changeWithVisibleCallback(comment, () => {});
+ changeWithVisibleCallback(comment, () => {comment.scrollIntoView()});
}
// Curry callback for moving downpage