diff options
| author | Nick Spreitzer <nick@200-ok.com> | 2020-10-30 12:09:44 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-10-30 22:39:44 +0530 |
| commit | 55107fcfc2d79ee0fd713d33f9775f0af842487f (patch) | |
| tree | a100914d65b17599612ffc5b80374b63acc46697 /layouts | |
| parent | 0a7a5407615e241636c931e56441a5fd8d5b621d (diff) | |
footer: Fix broken anchor link scrolling (#64)
fixes: Footnotes anchor link hrefs such as `#fn:1`
fixes: ToC anchors failing with hrefs having numbers.
based-on: https://stackoverflow.com/a/51396346/300212
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/partials/footer.html | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index b94ace0..f3baf82 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -30,8 +30,8 @@ document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener("click", function (e) { e.preventDefault(); - - document.querySelector(this.getAttribute("href")).scrollIntoView({ + var id = this.getAttribute("href").substr(1); + document.querySelector(`[id='${id}']`).scrollIntoView({ behavior: "smooth" }); }); |
