title: Javascript scroll function
body: <p>I made my own scroll function in javascript using an event listener with the mouse wheel, the problem is, the function allows the user to keep scrolling down roughly to far rather than stop once they have reached the bottom of the scrolling div.. </p>
  
  <p>This is what i have:
  <a href="http://jsfiddle.net/RjEr7/7/">http://jsfiddle.net/RjEr7/7/</a></p>
  
  <p>The function in question:</p>
  
  <pre><code>function do_it(e){
      var jump = 50;
      var parentHeight = parseInt(this.parentNode.offsetHeight)-50;
      var childHeight = parseInt(this.offsetHeight);
      var i = parseInt(this.style.marginTop, 10) || 0;
      var wheel = e.wheelDeltaY;
      var childHeightNew = childHeight + i;
  
      if(wheel == -120){
          if(childHeightNew &gt; parentHeight){                                                  
                  i -= jump;  
          }
      }else if(wheel == 120){
          if( (childHeightNew &lt; childHeight) &amp;&amp; i &lt; 0){
                  i += jump;
              if(i&gt;0){
                      i=0;
              }
          }
      }
  this.style.marginTop = i + 'px';
  }
  </code></pre>
  
  <p>In the JSfiddle, you will see the red box scrolls up too far. Not sure how to fix it though.</p>
  
  <p>Please help.</p>