function transformHeading() {
  const sections = document.querySelectorAll(".section");
  const heading = document.querySelectorAll(".section__heading");

  window.addEventListener("scroll", function () {
    let currentSection = "";

    sections.forEach(function (section) {
      const sectionTop = section.offsetTop;
      const sectionHeight = section.clientHeight;

      if (pageYOffset >= sectionTop - sectionHeight / 2) {
        currentSection = section.getAttribute("id");
      }
    });

    heading.forEach(function (head) {
      head.style.transform = `translateX(-100vw)`;
      if (head.dataset.heading === currentSection) {
        head.style.transform = `translateX(0%)`;
      }
    });
  });
}
//makes heading animation according to active section
makes heading animation according to active section
makes heading animation according to active section
function transformHeading() {
  const sections = document.querySelectorAll(".section");
  const heading = document.querySelectorAll(".section__heading");
  window.addEventListener("scroll", function () {
    let currentSection = "";
    sections.forEach(function (section) {
      const sectionTop = section.offsetTop;
      const sectionHeight = section.clientHeight;
      if (pageYOffset >= sectionTop - sectionHeight / 2) {
        currentSection = section.getAttribute("id");
      }
    });
    heading.forEach(function (head) {
      head.style.transform = `translateX(-100vw)`;
      if (head.dataset.heading === currentSection) {
        head.style.transform = `translateX(0%)`;
      }
    });
  });
}
function transformHeading ( ) { const sections = document . querySelectorAll ( ".section" ) ; const heading = document . querySelectorAll ( ".section__heading" ) ; window . addEventListener ( "scroll" , function ( ) { let currentSection = "" ; sections . forEach ( function ( section ) { const sectionTop = section . offsetTop ; const sectionHeight = section . clientHeight ; if ( pageYOffset >= sectionTop - sectionHeight / 2 ) { currentSection = section . getAttribute ( "id" ) ; } } ) ; heading . forEach ( function ( head ) { head . style . transform = ` ` ; if ( head . dataset . heading === currentSection ) { head . style . transform = ` ` ; } } ) ; } ) ; }
makes heading animation according to active section
makes heading animation according to active section