consolidate code in fragment jumper
authorDan Allen <dan@opendevise.com>
Mon, 21 Dec 2020 00:00:22 +0000 (17:00 -0700)
committerDan Allen <dan@opendevise.com>
Mon, 21 Dec 2020 00:00:22 +0000 (17:00 -0700)
src/js/03-fragment-jumper.js

index 5f9462a..68f580d 100644 (file)
@@ -9,11 +9,7 @@
   }
 
   function computePosition (el, sum) {
-    if (article.contains(el)) {
-      return computePosition(el.offsetParent, el.offsetTop + sum)
-    } else {
-      return sum
-    }
+    return article.contains(el) ? computePosition(el.offsetParent, el.offsetTop + sum) : sum
   }
 
   function jumpToAnchor (e) {