title: Javascript window.scrollBy speeds up
body: <p>I have a project I'm working on with a site that receives information and displays it in a table.  If the table is larger than the screen, the page will automatically scroll down, and when it hits the bottom, back up, and repeat, repeat, up and down.</p>
  
  <p>The issue I'm having is that every time I send a chunk of data to the site, the speed of the scrollBy increases.  Every refresh scroll incrementally faster, up and down. </p>
  
  <p>Here is the code:</p>
  
  <pre><code>window.onload = function() {
  
     ...
          buildHeader(event);
          buildTable(event);
    };
  
  
  
  
  function buildTable(event) {
   ...
  
    if((+tableHeight) &gt; window.innerHeight){
  
       pageScroll();
    }
  
  }
  
  
  
  
  
   var scrollDirection = 1;
   function pageScroll() {
     window.scrollBy(0,scrollDirection); // horizontal and vertical scroll increments
     scrolldelay = setTimeout('pageScroll()',50); // scrolls every 50 milliseconds
  
     if ( (window.scrollY === 0) || (window.innerHeight + window.scrollY) &gt;=                   document.body.offsetHeight) {
      scrollDirection = -1*scrollDirection;
     }
  
  }
  </code></pre>
  
  <p>I would like to know why each time the page is sent information the speed increases.  Isit necessary to cancel an occurring scrollBy before calling it again?</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks
  Josh</p>