on master help sign in
docs scrolls into view
commitf5f6c7920148cea0621a5c4eef5b4a6fa24acbb4 authorMatilde Park <matilde@tlon.io> dateThu 31 Oct 2019, 15:13 (7 years ago) parentca42792
1 file changed+13
static/scripts.js+13
static/scripts.js+13
@@ -325,7 +325,16 @@ if (document.readyState === "complete" ||
325325 });
326326}
327327
328+// Scroll to current document in nav list.
329+let docsNavScroll = function() {
330+ let docsDetails = document.querySelectorAll("nav ul details")
331+ for (let details in docsDetails) {
332+ if (docsDetails[details].open) docsDetails[details].scrollIntoView()
333+ }
334+}
335+
328336if (window.location.href.includes("docs")) {
337+ // tooltip behaviour for standard library page
329338 tippy('.tooltip', {
330339 content(reference) {
331340 const title = reference.getAttribute('title')
@@ -336,6 +345,8 @@ if (window.location.href.includes("docs")) {
336345 animation: 'fade'
337346 })
338347
348+ // on mobile, dropdown selections go to the option
349+
339350 let docsSelect = document.getElementById('docsSelect');
340351 let goTo = function() {
341352 let url = docsSelect.options[docsSelect.selectedIndex].value;
@@ -345,6 +356,8 @@ if (window.location.href.includes("docs")) {
345356 }
346357
347358 docsSelect.addEventListener('change', goTo);
359+ // docs autoscroll to current page
360+ docsNavScroll();
348361}
349362
350363// same-page navigation on-scroll behaviour