I tried two solutions.
1. https://github.com/istvan-ujjmeszaros/bootstrap-autohidingnavbar but It doesn't work with data-spy = affix
2. I used a custom script
<script>
var prevScrollpos = window.pageYOffset;
window.onscroll = function() {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("t3-mainnav").style.top = "0";
} else {
document.getElementById("t3-mainnav").style.top = "-52px";
}
prevScrollpos = currentScrollPos;
if (currentScrollPos > 0) {document.getElementById("t3-header").style.marginBottom = "52px";}
if (currentScrollPos <= 0) document.getElementById("t3-header").style.marginBottom = "0";
}
</script>
But problem is the page twitches when menu appears. This happens when <nav> element switch position from fixed to relative. I tried to compensate it with .style.marginBottom for next element in DOM. But unsuccessful.