"use strict"; /* ======= Header animation ======= */ const header = document.getElementById('header'); window.onload=function() { headerAnimation(); }; window.onresize=function() { headerAnimation(); }; window.onscroll=function() { headerAnimation(); }; function headerAnimation () { var scrollTop = window.scrollY; if ( scrollTop > 0 ) { header.classList.add('navbar-fixed-top'); } else { header.classList.remove('navbar-fixed-top'); } }; let scrollLinks = document.querySelectorAll('.scrollto'); const pageNavWrapper = document.getElementById('navbar-collapse'); scrollLinks.forEach((scrollLink) => { scrollLink.addEventListener('click', (e) => { e.preventDefault(); let element = document.querySelector(scrollLink.getAttribute("href")); const yOffset = 70; //page .header height //console.log(yOffset); const y = element.getBoundingClientRect().top + window.pageYOffset - yOffset; window.scrollTo({top: y, behavior: 'smooth'}); //Collapse mobile menu after clicking if (pageNavWrapper.classList.contains('show')){ pageNavWrapper.classList.remove('show'); } }); }); /* ===== Gumshoe SrollSpy ===== */ /* Ref: https://github.com/cferdinandi/gumshoe */ // Initialize Gumshoe var spy = new Gumshoe('#nav-menu .nav-link', { offset: 70 });