title: how to stop scroll event
body: <p>Hello i have 2 functions , first detect sroll direction up/down , and launch other function (autoscrolling). How to force stop .scroll() function after call ? now it's look's like infinity loop...</p>
  
  <pre><code>var pageScroll = function(){
  
      var iScrollPos = 0;
  
      $(window).scroll(function(e){
  
          var iCurScrollPos = $(this).scrollTop();
  
              if (iCurScrollPos &gt; iScrollPos) {
  
                  App.scrollto((currentPage+1));
  
              } else {
  
                  App.scrollto((currentPage-1));
  
              }
  
          iScrollPos = iCurScrollPos;
  
      });
  
  }
  </code></pre>
  
  <p>and called functions</p>
  
  <pre><code>    scrollto: function(page){
  
          var section_offset = $('section[data-page="'+page+'"]').offset().top;
  
          $('html, body').animate({ scrollTop: section_offset }, 'slow',function(){
  
              $('html, body').stop();
              currentPage = page;
              console.log(currentPage);
  
          });
  
      }
  </code></pre>
  
  <p>and console log screen <a href="http://prntscr.com/4m493q" rel="nofollow">http://prntscr.com/4m493q</a> (infinity loop)</p>