diff --git a/src/js/main.js b/src/js/main.js index 1dcf7d9..f01e6d4 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -8,17 +8,17 @@ const intercept = document.createElement("div"); intercept.setAttribute("data-observer-intercept", ""); header.before(intercept); -const observer2 = new IntersectionObserver(([entry]) => { +const observer = new IntersectionObserver(([entry]) => { header.classList.toggle("scroll", !entry.isIntersecting); }); -observer2.observe(intercept); +observer.observe(intercept); // Update navigation according to page scroll const options = { rootMargin: '0px 0px -60% 0px' }; -const observer = new IntersectionObserver(entries => { +const sectionObserver = new IntersectionObserver(entries => { entries.forEach(entry => { const id = entry.target.getAttribute("id"); if (entry.isIntersecting) { @@ -34,7 +34,7 @@ const observer = new IntersectionObserver(entries => { },options); document.querySelectorAll('section').forEach(function(section, i) { - observer.observe(section); + sectionObserver.observe(section); }); // Random accent font & color