I'm developing a website using the plugin Locomotive Scroll to create a smooth scrolling experience. The plugin works fine. However, I would like to have a fixed header (top menu) with the typical reduce height effect when starting scrolling the page.
I can't find the way to make my fixed header effect working with Locomotive Scroll on the same page.
Here is the JS code for Locomotive Scroll:
document.documentElement.classList.add('is-loaded');
document.documentElement.classList.remove('is-loading');
setTimeout(() => {
document.documentElement.classList.add('is-ready');
},300)
setTimeout(() => {
const scroll = new LocomotiveScroll({
el: document.querySelector('[data-scroll-container]'),
smooth: true,
smoothMobile: true,
getSpeed: true,
getDirection: true,
useKeyboard: true
});
}, 1000);
And the jQuery code for my header effect:
$(window).scroll(function() {
if ($(this).scrollTop() > 1){
$('.site_header').removeClass('is--large').addClass('is--small');
}
else{
$('.site_header').removeClass('is--small').addClass('is--large');
}
});
Any help would be much appreciated, thanks!