Fix smooth scrolling for footnotes (#103)

Footnotes are using a fragment format with a colon inside ("#fn:1" for
example). However, ":" is a special character for jQuery
(http://api.jquery.com/category/selectors/), thus the target anchor is
never found and the scrolling does not happen.

This change selects the right target element using vanilla Javascript to
bypass special characters that could be in the fragment part.
This commit is contained in:
Etienne Membrives 2018-11-13 11:03:07 +01:00 committed by Hanzei
parent 5afb81ca58
commit 826b4c2c9f

View file

@ -22,7 +22,7 @@ document.addEventListener("DOMContentLoaded", function () {
$("a[href^=\"#\"]").click(function(e) {
e.preventDefault();
$("html, body").animate({
scrollTop: $(this.hash).offset().top
scrollTop: $(document.getElementById(this.hash.substr(1))).offset().top
}, 500);
$("#nav-menu").removeClass("is-active");
return true;