Fix: make smoothscroll work with markdown links & update broken links (glossary) #234
1 changed files with 1 additions and 1 deletions
2
app/dist/scripts/app.js
vendored
2
app/dist/scripts/app.js
vendored
|
@ -36,7 +36,7 @@ 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
|
||||
history.replaceState({}, "", `#${element}`); // Add hash to URL bar
|
||||
}
|
||||
});
|
||||
@Wick ^ @Wick ^
Tested on the overview page + api page and it smooth scrolls as it should and updates the URL. My reasoning behind the change was that if it manages to successfully find an element to scroll to it can safely be added to browser history. I noticed a related issue though: that when smooth-scrolling occurs it wont get properly placed in browser history, on current site as well (navigate with the sidebar then click back in the browser). Let me know if you need anything more :) Tested on the overview page + api page and it smooth scrolls as it should and updates the URL. My reasoning behind the change was that if it manages to successfully find an element to scroll to it can safely be added to browser history.
I noticed a related issue though: that when smooth-scrolling occurs it wont get properly placed in browser history, on current site as well (navigate with the sidebar then click back in the browser).
My latest commit will fix this by changing from history.replaceState to history.pushState for updating browser history.
Let me know if you need anything more :)
Sweet, sounds good to me. Thanks! Sweet, sounds good to me. Thanks!
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue
Does removing this block affect other pages? For example, if I click a glossary link from the Overview page, will the smooth scroll and anchoring happen?
I'm not sure how to checkout your branch to test myself.