Q:

Create hide button for navbar

I've created this collapsable navbar that works nicely, 
everytime scrolldown navbar show and everytime scrolltop navbar hide
I would like with show up navbar hide bottom is visible to users can hide navbar . 
show/hide button should be scrollUP with navbar and everytime navar hiden this button visible to user ! 
Any way to do this?

// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('header').outerHeight();

$(window).scroll(function(event) {
  didScroll = true;
});

setInterval(function() {
  if (didScroll) {
    hasScrolled();
    didScroll = false;
  }
}, 250);

function hasScrolled() {
  var st = $(this).scrollTop();

  // Make sure they scroll more than delta
  if (Math.abs(lastScrollTop - st) <= delta)
    return;

  // If they scrolled down and are past the navbar, add class .nav-up.
  // This is necessary so you never see what is "behind" the navbar.
  if (st > lastScrollTop && st > navbarHeight) {
    // Scroll Down
    $('header').removeClass('nav-up').addClass('nav-down');
  } else {
    // Scroll Up
    if (st + $(window).height() < $(document).height()) {
      $('header').removeClass('nav-down').addClass('nav-up');
    }
  }

  lastScrollTop = st;
}
body {
  padding-top: 40px;
}

header {
  background: #f5b335;
  height: 40px;
  position: fixed;
  bottom: 0;
  transition: bottom 0.2s ease-in-out;
  width: 100%;
}

.nav-up {
  bottom: -40px;
}

main {
  background: url() repeat;
  height: 2000px;
}

footer {
  background: #ddd;
}

* {
  color: transparent
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header class="nav-down">
  This is your menu.
</header>
<main>
  This is your body.
</main>
<footer>
  This is your footer.
</footer>

Anyone know of a good way to write this?
thanks for your helps............................

A:

Check this solution.

Edited

// Hide Header on on scroll down
var didScroll;
var lastScrollTop = 0;
var delta = 5;
var navbarHeight = $('header').outerHeight();

$(window).scroll(function(event) {
  didScroll = true;
});

setInterval(function() {
  if (didScroll) {
    hasScrolled();
    didScroll = false;
  }
}, 250);

function hasScrolled() {
  var st = $(this).scrollTop();

  // Make sure they scroll more than delta
  if (Math.abs(lastScrollTop - st) <= delta)
    return;

  // If they scrolled down and are past the navbar, add class .nav-up.
  // This is necessary so you never see what is "behind" the navbar.
  if (st > lastScrollTop && st > navbarHeight) {
    // Scroll Down
    if ($('header a').hasClass('Down-Arrow')){
    $('header').removeClass('nav-up').addClass('nav-down');
    } else {
    $('.UP-Arrow').addClass('hide-arrow');
    }

  } else {
    // Scroll Up
    if (st + $(window).height() < $(document).height()) {
      $('.UP-Arrow').removeClass('hide-arrow');
      $('header').removeClass('nav-down').addClass('nav-up');
    }
  }

  lastScrollTop = st;
}

$(document).on('click','.Down-Arrow',function(){
$(this).removeClass('Down-Arrow').addClass('UP-Arrow');
$('header').removeClass('nav-down').addClass('nav-up');
});

$(document).on('click','.UP-Arrow',function(){
$(this).removeClass('UP-Arrow').addClass('Down-Arrow');
    $('header').removeClass('nav-up').addClass('nav-down');
});
body {
  padding-top: 40px;
}

header {
  background: #f5b335;
  height: 40px;
  position: fixed;
  bottom: 0;
  transition: bottom 0.2s ease-in-out;
  width: 100%;
}

header a{
color:#000;
position:absolute;
width:30px;
height:30px;
padding:5px;
background:#f5b335;
bottom:40px;
right:20px;
border-radius: 2px 2px 0 0;
text-align:center;
transition-duration:0.3s;
cursor:pointer;
}

.Down-Arrow:after{
content: "˅";
position:absolute;
top:15px;
left:15px;
}

.UP-Arrow:after{
content: "˄";
position:absolute;
top:15px;
left:15px;
}

header.nav-up .Down-Arrow{
bottom:0px;
}

.hide-arrow{
bottom: -40px;
}

.nav-up {
  bottom: -40px;
}

main {
  background: url() repeat;
  height: 2000px;
}

footer {
  background: #ddd;
}

* {
  color: transparent
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<header class="nav-down">
  This is your menu.
  <a class="Down-Arrow"></a>
</header>
<main>
  This is your body.
</main>
<footer>
  This is your footer.
</footer>

