title: Simulate top scroll using javascript setInterval & clearInterval
body: <p>I want to simulate scroll by moving body/html frame to the top/upwards by arbitrary amount. I know jQuery scroll or animate function, <code>.scroll()</code> and <code>.animate()</code>. But I have decided not to use it since it caused conflict between <code>scrollTop</code> property in <code>animate</code> and <code>.scroll()</code> jQuery native function when the animation happens and is still ongoing AND the <code>.scroll</code> gets called..</p>
  
  <p>My plan is now to just simulate scroll by moving body/html frame to the top as smooth as possible by some arbitrary amount, and then STOP (clear the interval) when there's a native <code>scroll</code> happens (<code>.scroll()</code> gets invoked).</p>
  
  <p>I am able to stop the <code>setInterval</code> animation when <code>.scroll()</code> is called, but I am still not able to move the html object to the top by the amount I want it to "scroll" (which means my code only partially works).</p>
  
  <p>Here is what I have so far:</p>
  
  <pre><code>var scrollTop = //Some arbitrary value
  var fakeScroll = setInterval(function(){
        console.log(scrollTop);
        var animObj = $('html,body');
        animObj.top = animObj.offset().top + scrollTop;   
      },500);
      $(document).scroll(function(){
          clearInterval(fakeScroll);
      });
  </code></pre>
  
  <p>Appreciate any suggestions/answers. Thanks!</p>