reverse of .animate on scroll

reverse of .animate on scroll

hello.
i want to scale down my navbar on scrolling down and animate it back to normal by scrolling up.
The first step works perfect, but i don't get it resetted.
Any help appreciated,
snote

  1. $(function () {
  2.   var lastScrollTop = 0;
  3.   var $navbar = $('.navbar');
  4.   $(window).scroll(function(event){
  5.     var st = $(this).scrollTop();
  6.     if (st > lastScrollTop) {
  7.        $navbar.animate({
  8.         right: '10px',
  9.          width: '150px'
  10.        }, 2000, "linear");
  11.         
  12.     } else {
  13.             $("navbar").removeClass("animate")
  14.          }
  15.     lastScrollTop = st;
  16.   });
  17. });