@@ -314,18 +314,7 @@ if (document.readyState === "complete" ||
314314 });
315315}
316316
317−// Scroll to current document in nav list.
318−// let docsNavScroll = function() {
319−// let docsNav = document.querySelectorAll("ul.content-nav__index a")
320−// for (let link in docsNav) {
321−// if (window.location.href.includes(docsNav[link].href)) {
322−// docsNav[link].scrollIntoView()
323−// }
324−// }
325−//}
326−
327317if (window.location.href.includes("docs")) {
328−// docsNavScroll();
329318 tippy('.tooltip', {
330319 content(reference) {
331320 const title = reference.getAttribute('title')
@@ -335,4 +324,47 @@ if (window.location.href.includes("docs")) {
335324 animateFill: false,
336325 animation: 'fade'
337326 })
327+}
328+
329+// same-page navigation on-scroll behaviour
330+
331+if (document.body.classList.contains("page-indiced")) {
332+let h2 = document.getElementsByTagName("h2");
333+let h3 = document.getElementsByTagName("h3");
334+let all = document.querySelectorAll("nav details li a");
335+let headers = document.querySelectorAll("details summary");
336+
337+// smooth scrolling on click
338+all.forEach(link => {
339+ link.addEventListener("click", event => {
340+ event.preventDefault();
341+ let target = document.querySelector(event.target.hash);
342+ target.scrollIntoView({
343+ behavior: "smooth",
344+ block: "start"
345+ });
346+ });
347+});
348+
349+let lastId;
350+let cur = [];
351+
352+window.addEventListener("scroll", event => {
353+ let fromTop = window.scrollY;
354+
355+ all.forEach(link => {
356+ let section = document.querySelector(link.hash);
357+
358+ if (
359+ section.offsetTop <= fromTop &&
360+ section.offsetTop + section.offsetHeight > fromTop
361+ ) {
362+ link.classList.add("current");
363+ } else {
364+ link.classList.remove("current");
365+ }
366+ });
367+
368+});
369+
338370}