I created a simple page with content and a sidebar. When the user scrolls, the sidebar goes down. When the sidebar is small it works right, but when the sidebar is large it gets down infinitely.
I created a demo page for better explanation.
In this first example, the sidebar is small so it works correct (http://jsbin.com/ojasuj/2/)
In this second example, the sidebar is large then it goes infinitely down (http://jsbin.com/ojasuj/).
I want to stop the animation at the bottom. I am using this javascript:
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery( document ).scroll( function() {
if( jQuery(document).scrollTop() <= ( jQuery(document).height() - jQuery(window).height() ) ) {
jQuery(".sidebar").stop().animate({"marginTop": ( jQuery(document).scrollTop() + 10 ) + "px"}, "slow" );
} else {
jQuery(".sidebar").css({'margin-bottom': '100px'});
}
});
});
I tried several ways but could not solve this problem. I tried to use some scripts, but they also did not work. I hope someone can help me.