Clearer order of operations
[hnim.git] / hnim.js
diff --git a/hnim.js b/hnim.js
index ab854f8..7ac3f5d 100644 (file)
--- 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) => {
@@ -51,7 +51,7 @@
     change(e.target.closest("tr.athing"));
   })
   document.addEventListener("keydown", (e) => {
-    if (e.isComposing) {
+    if (e.target.type === 'textarea' || e.isComposing) {
       return;
     }
     switch (e.key) {