"footnotes" -> ".footnotes"; use idFromHash()

This commit is contained in:
Nate Weaver 2020-02-24 12:15:04 -06:00
parent 76dd3abff2
commit 5bbda2a68e
1 changed files with 5 additions and 5 deletions

View File

@ -152,10 +152,10 @@
document.addEventListener("click", (ev) => document.addEventListener("click", (ev) =>
{ {
if (!(ev.target && ev.target instanceof HTMLAnchorElement)) return; if (!(ev.target && ev.target instanceof HTMLAnchorElement)) return;
if (!ev.target.matches(".footnotes .reversefootnote, .footnotes .footnoteBackLink, footnotes .footnote-return")) return; if (!ev.target.matches(".footnotes .reversefootnote, .footnotes .footnoteBackLink, .footnotes .footnote-return")) return;
const hash = ev.target.hash; const id = idFromHash(ev.target);
if (!hash) return; if (!id) return;
const fnref = document.getElementById(hash.substring(1)); const fnref = document.getElementById(id);
window.scrollTo({ top: fnref.getBoundingClientRect().top + window.scrollY }); window.scrollTo({ top: fnref.getBoundingClientRect().top + window.scrollY });
ev.preventDefault(); ev.preventDefault();