$(function() { if ($(window).scrollTop() === 0){ $('.navbar').addClass('top'); } $(window).scroll(function (event) { var scroll = $(window).scrollTop(); if (scroll !== 0 ){ $('.navbar').removeClass('top'); } else if (scroll === 0){ $('.navbar').addClass('top'); } }); new Waypoint({ element: $('#divided-hero'), handler: function() { $(".nav-link").removeClass('active'); $("."+this.options.element[0].id).addClass('active'); }, offset: 'bottom-in-view' }); new Waypoint({ element: $('#schedule'), handler: function() { $(".nav-link").removeClass('active'); $("."+this.options.element[0].id).addClass('active'); }, offset: 'bottom-in-view' }); new Waypoint({ element: $('#resources'), handler: function() { $(".nav-link").removeClass('active'); $("."+this.options.element[0].id).addClass('active'); }, offset: 'bottom-in-view' }); new Waypoint({ element: $('#contact'), handler: function() { $(".nav-link").removeClass('active'); $("."+this.options.element[0].id).addClass('active'); }, offset: 'bottom-in-view' }); $('.nav-link').on('click', function(e){ e.preventDefault(); $('html, body').animate({ scrollTop: $("#" + e.currentTarget.classList[1]).offset().top }, 1000, function(){ $(".nav-link").removeClass('active'); $("." + e.currentTarget.classList[1]).addClass('active'); }); }); });