@@ -314,18 +314,7 @@ if (document.readyState === "complete" ||
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()
327if (window.location.href.includes("docs")) {
317if (window.location.href.includes("docs")) {
329 tippy('.tooltip', {
318 tippy('.tooltip', {
330 content(reference) {
319 content(reference) {
331 const title = reference.getAttribute('title')
320 const title = reference.getAttribute('title')
@@ -335,4 +324,47 @@ if (window.location.href.includes("docs")) {
335 animateFill: false,
324 animateFill: false,
336 animation: 'fade'
325 animation: 'fade'
329+// same-page navigation on-scroll behaviour
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");
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({
352+window.addEventListener("scroll", event => {
353+ let fromTop = window.scrollY;
355+ all.forEach(link => {
356+ let section = document.querySelector(link.hash);
359+ section.offsetTop <= fromTop &&
360+ section.offsetTop + section.offsetHeight > fromTop
362+ link.classList.add("current");
364+ link.classList.remove("current");