Docs navigation scrolls to current article on load
commit7ace837e91eedb4c9f55e598f4ef95b559e23950
authorMatilde Park <matilde@tlon.io>
dateFri 26 Jul 2019, 17:42 (7 years ago)
parent8ef328e
sass/_main.scss+5
@@ -76,6 +76,11 @@ iframe {
7676 font-size: inherit;
7777 line-height: inherit;
7878 }
79+ li a:focus {
80+ outline: 0;
81+ border: none;
82+ -moz-outline-style: none;
83+ }
7984}
8085
8186.content-nav-icon {
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 (docsNav[link].href === window.location.href) {
338+ docsNav[link].focus()
339+ }
340+ }
341+}
342+
343+if (window.location.href.includes("docs")) docsNavScroll();