From: Jacob Casper Date: Thu, 10 Feb 2022 18:00:07 +0000 (-0600) Subject: Don't infinite loop on comments larger than window X-Git-Tag: v0.7~1 X-Git-Url: https://git.jacobcasper.com/?p=hnim.git;a=commitdiff_plain;h=91f9300708138dfc9a540f39e972306ff2ba2042 Don't infinite loop on comments larger than window --- diff --git a/hnim.js b/hnim.js index 3910014..aab3bc0 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) => {