]> jfr.im git - irc/freenode/web-7.0.git/blobdiff - static/js/utils.js
honour navbar when scrolling to anchor
[irc/freenode/web-7.0.git] / 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