I fixed it!
Create this id:
#t4-header {
background-color: #fff;
position: sticky;
width: 100%;
display: flex;
transition: top 0.3s;
}
and add this before </body>:
<script>
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (currentScrollPos<300) {
document.getElementById("t4-header").style.top = "0";
} else
if (prevScrollpos > currentScrollPos) {
document.getElementById("t4-header").style.top = "0";
} else {
document.getElementById("t4-header").style.top = "-150px";
}
prevScrollpos = currentScrollPos;
}
</script>
if you need fix menu:
<script>
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (currentScrollPos<300) {
document.getElementById("t4-header").style.top = "0";
} else
if (prevScrollpos > currentScrollPos) {
document.getElementById("t4-header").style.top = "0";
} else {
document.getElementById("t4-header").style.top = "0";
}
prevScrollpos = currentScrollPos;
}
</script>