<jazcaratec/>

show-hide header on scroll in elementor pro

<script>

document.addEventListener(‘DOMContentLoaded’, function() {
jQuery(function($) {
var mywindow = $(window);
var mypos = mywindow.scrollTop();
let scrolling = false; /* For throlling scroll event */
window.addEventListener(‘scroll’, function() {
scrolling = true;
});
setInterval(() => {
if (scrolling) {
scrolling = false;
if (mypos > 40) {
if (mywindow.scrollTop() > mypos) {
$(‘#stickyheaders’).addClass(‘headerup’);
} else {
$(‘#stickyheaders’).removeClass(‘headerup’);
}
}
mypos = mywindow.scrollTop();
}
}, 300);
});
});

</script>
<style>
#stickyheaders{
transition : transform 0.34s ease;
}
.headerup{
transform: translateY(-110px); /*adjust this value to the height of your header*/
}
</style>

Entradas relacionadas