]> jfr.im git - irc/freenode/web-7.0.git/commitdiff
honour navbar when scrolling to anchor
authorSvante Bengtson <redacted>
Thu, 17 May 2018 13:02:10 +0000 (15:02 +0200)
committerChristel Dahlskjaer <redacted>
Thu, 24 May 2018 23:49:12 +0000 (00:49 +0100)
static/js/utils.js

index 52c8eb74fa31a2a8216822eead9a170d487635ca..06a5b872eed558d21adce117f46035553e811db2 100755 (executable)
@@ -13,3 +13,11 @@ document.addEventListener('copy', function (event) {
   event.clipboardData.setData('text/html', newText.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;'))
   event.preventDefault()
 })
+
+/**
+ * Scroll the page to honour the fixed navbar when linked to an anchor
+ * @return {Undefined}
+ */
+function shiftWindow () { if (window.location.hash) window.scrollBy(0, -50) };
+window.addEventListener('hashchange', shiftWindow)
+window.onload = shiftWindow