animate .scroll

animate .scroll

Why are not working?
  1. var tempScrollTop, currentScrollTop = 0;
  2. $(window).scroll(function(){
  3. currentScrollTop = $("html").offset().top;
  4. if (tempScrollTop < currentScrollTop)
  5. {
  6. $("html:not(:animated),body:not(:animated)").animate({scrollTop: margintop_html+120}, 500);
  7. }
  8. else if(tempScrollTop > currentScrollTop)
  9. {
  10. $("html:not(:animated),body:not(:animated)").animate({scrollTop: margintop_html-120}, 500);
  11. }
  12. tempScrollTop = currentScrollTop;
  13. });