on master help sign in
Merge pull request #158 from matildepark/docs-scrolling

Docs navigation scrolls to current article on load

commit37083fcc05c628d0a0548a1ad6b73503557cc9d9 authorMorgan Sutherland <msutherl@users.noreply.github.com> dateTue 30 Jul 2019, 11:19 (7 years ago) parent7a368d206429fc
1 file changed+12
static/scripts.js+12
static/scripts.js+12
@@ -329,3 +329,15 @@ if (document.readyState === "complete" ||
329329 initHotKeys();
330330 });
331331}
332+
333+// Scroll to current document in nav list.
334+let docsNavScroll = function() {
335+ let docsNav = document.querySelectorAll("ul.content-nav__index a")
336+ for (let link in docsNav) {
337+ if (window.location.href.includes(docsNav[link].href)) {
338+ docsNav[link].scrollIntoView()
339+ }
340+ }
341+}
342+
343+if (window.location.href.includes("docs")) docsNavScroll();