refactor(app.js, glossary): make smoothscroll work with links in md

This commit is contained in:
Wick 2019-01-25 11:59:23 +01:00
parent 18bb4da76c
commit eb618cc874

View file

@ -36,13 +36,8 @@ document.querySelectorAll("a[href^='#']").forEach(anchor => {
if (document.getElementById(element)) {
elementOffset = document.getElementById(element).offsetTop - 74;
window.scroll({ top: elementOffset, behavior: "smooth" });
history.replaceState({}, "", `#${element}`); // Add hash to URL bar
}
// Add hash to URL bar when sidebar links are clicked
if (
event.target.parentElement.className === "api__toc__item" ||
event.target.parentElement.parentElement.className === "component--glossary-toc"
) history.replaceState({}, "", `#${element}`);
});
});