const observer2 = new IntersectionObserver(entries => { entries.forEach(entry => { const id = entry.target.getAttribute("id"); if (entry.isIntersecting) { document.querySelectorAll(".active").forEach((z) => { z.classList.remove("active") }); document.querySelector(`a[href="#${id}"]`).classList.add("active"); }}); }, { rootMargin: '0px 0px -50% 0px' }); $('#dam-tab-element.tab-element').each(function(e){ if($(this).is(':visible')) { document.getElementById("dam-tab-element11").querySelectorAll("h2:not(.w-dyn-bind-empty)").forEach(function(heading, i) { observer1.observe(heading); heading.setAttribute("id", "toc-" + i); // gives each h2 a unique id let str = heading.innerHTML; // adds section titles to slugs str = str.replace(/\s+/g, '-').replace(/[°&\/\\#,+()$~%.'":;*?<>{}]/g, "").toLowerCase(); // replaces spaces with hyphens, removes special characters and extra spaces from the headings, and applies lowercase in slugs heading.setAttribute("id", str); // gives each heading a unique id const item = document.createElement("a"); // creates an anchor element called "item" for each h2 item.innerHTML = heading.innerHTML // gives each item the text of the corresponding heading item.setAttribute("class", "tab-link-text"); // gives each item the correct class item.setAttribute("href", "#" + str); // gives each item the correct anchor link document.querySelector("#dam-tablink11").appendChild(item); // places each item inside the Table of Contents div }); } }); var button = document.getElementById('slide1'); button.onclick = function () { var container = document.getElementById('container1'); sideScroll(container,'right',25,170,5);}; var back = document.getElementById('slideBack1'); back.onclick = function () { var container = document.getElementById('container1'); sideScroll(container,'left',25,170,5);}; function sideScroll(element,direction,speed,distance,step){ scrollAmount = 0; var slideTimer = setInterval(function(){ if(direction == 'left'){ element.scrollLeft -= step; } else { element.scrollLeft += step;} scrollAmount += step; if(scrollAmount >= distance){ window.clearInterval(slideTimer);} }, speed);}