<script>

var navBar = document.querySelector('#header')
var lastScrollTop = 10;

window.addEventListener("scroll", function(){ // or window.addEventListener("scroll"....
   var st = window.pageYOffset < 200 || document.documentElement.scrollTop;
   if (st > lastScrollTop){
    navBar.classList.add('inactive');
   } else {
    navBar.classList.remove('inactive');
   }
   lastScrollTop = st;
}, false);

</script>
<style>
header {
    transition: all .2s ease-in-out;
}

header.inactive {
    transform: translateY(-100%);
    transition: all .2s ease-in-out;
}
</style>