I am having an issue where I get a uncaught type error, but the script still works. I would like to resolve this but cannot seem to see the issue. Any help is greatly appreciated! Script is below.
StickyNav: function() {
let mainNavLinks = document.querySelectorAll(".js-pdp-link");
let mainSections = document.querySelectorAll("section");
let lastId;
let cur = [];
window.addEventListener("scroll", event => {
let fromTop = window.scrollY + 70;
mainNavLinks.forEach(link => {
let section = document.querySelector(link.hash);
if (section.offsetTop <= fromTop && section.offsetTop + section.offsetHeight > fromTop) {
link.classList.add("js-active");
} else {
link.classList.remove("js-active");
}
});
});
}