Fix: make smoothscroll work with markdown links & update broken links (glossary) #234

Merged
Wick merged 5 commits from fix-glossary into master 2019-01-25 19:05:35 +01:00
Showing only changes of commit 1d44d258b5 - Show all commits

View file

@ -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.pushState({}, "", `#${element}`); // Add hash to URL bar
}
});
NetOpWibby commented 2019-01-25 18:00:59 +01:00 (Migrated from github.com)
Review

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?

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?
NetOpWibby commented 2019-01-25 18:01:40 +01:00 (Migrated from github.com)
Review

I'm not sure how to checkout your branch to test myself.

I'm not sure how to checkout your branch to test myself.
NetOpWibby commented 2019-01-25 19:01:15 +01:00 (Migrated from github.com)
Review

@Wick ^

@Wick ^
Wick commented 2019-01-25 19:04:46 +01:00 (Migrated from github.com)
Review

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 :)

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 :)
NetOpWibby commented 2019-01-25 19:05:22 +01:00 (Migrated from github.com)
Review

Sweet, sounds good to me. Thanks!

Sweet, sounds good to me. Thanks!
});