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..
This is what i have: http://jsfiddle.net/RjEr7/7/
The function in question:
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 > parentHeight){
i -= jump;
}
}else if(wheel == 120){
if( (childHeightNew < childHeight) && i < 0){
i += jump;
if(i>0){
i=0;
}
}
}
this.style.marginTop = i + 'px';
}
In the JSfiddle, you will see the red box scrolls up too far. Not sure how to fix it though.
Please help.