X-Git-Url: https://jfr.im/git/irc/freenode/web-7.0.git/blobdiff_plain/3f51f0f910da2c4fdc7fb7eb08b27e954191af07..2b4a60ab8266dc1548c4d2928e03584378a2df88:/static/js/utils.js diff --git a/static/js/utils.js b/static/js/utils.js index 52c8eb74f..06a5b872e 100755 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -13,3 +13,11 @@ document.addEventListener('copy', function (event) { event.clipboardData.setData('text/html', newText.replace(/&/g, '&').replace(//g, '>')) 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