X-Git-Url: https://git.jacobcasper.com/?p=hnim.git;a=blobdiff_plain;f=hnim.js;h=1e804b37762f0f57bdf47f24ac2c6bad3d897421;hp=391001410e04b533132bbc749efccef96d906a3d;hb=HEAD;hpb=066f03c1004a1182338538e8f59d7fb39f208f0a diff --git a/hnim.js b/hnim.js index 3910014..1e804b3 100644 --- a/hnim.js +++ b/hnim.js @@ -15,7 +15,7 @@ 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) => { @@ -32,7 +32,7 @@ const change = (comment) => { elementsIndex = elements.indexOf(comment); - changeWithVisibleCallback(comment, () => {}); + changeWithVisibleCallback(comment, () => {comment.scrollIntoView()}); } // Curry callback for moving downpage