function navActive() {
  const sections = document.querySelectorAll(".section");
  const icons = document.querySelectorAll(".nav__link i");

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

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

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

    icons.forEach(function (icon) {
      icon.classList.remove("active");
      if (icon.dataset.icon === currentSection) {
        icon.classList.add("active");
      }
    });
  });
}
//makes links active according to location
makes links active according to location
makes links active according to location
function navActive() {
  const sections = document.querySelectorAll(".section");
  const icons = document.querySelectorAll(".nav__link i");
  window.addEventListener("scroll", function (e) {
    let currentSection = "";
    sections.forEach(function (section) {
      const sectionTop = section.offsetTop;
      const sectionHeight = section.clientHeight;
      if (pageYOffset >= sectionTop - sectionHeight / 3) {
        currentSection = section.getAttribute("id");
      }
    });
    icons.forEach(function (icon) {
      icon.classList.remove("active");
      if (icon.dataset.icon === currentSection) {
        icon.classList.add("active");
      }
    });
  });
}
function navActive ( ) { const sections = document . querySelectorAll ( ".section" ) ; const icons = document . querySelectorAll ( ".nav__link i" ) ; window . addEventListener ( "scroll" , function ( e ) { let currentSection = "" ; sections . forEach ( function ( section ) { const sectionTop = section . offsetTop ; const sectionHeight = section . clientHeight ; if ( pageYOffset >= sectionTop - sectionHeight / 3 ) { currentSection = section . getAttribute ( "id" ) ; } } ) ; icons . forEach ( function ( icon ) { icon . classList . remove ( "active" ) ; if ( icon . dataset . icon === currentSection ) { icon . classList . add ( "active" ) ; } } ) ; } ) ; }
makes links active according to location
makes links active according to location