The JS:
// Sticky Header const headerOffset = $('header').offset().top; $(window).on('scroll', function() { // If the scroll top is greater than the position of the header from the top of the window, add the "super-sticky" class. // Otherwise, remove the "super-sticky" class. if ($(window).scrollTop() > headerOffset) { $('header').addClass('super-sticky'); } else if ($(window).scrollTop() <= headerOffset) { $('header').removeClass('super-sticky'); } }); |