In my container there are sections/boxes, but the last one of these boxes should follow scrolling when none of the other boxes are visible.
So, when user sc
I needed the div to stop when it reach a certain object, so i did it like this:
var el = $('#followdeal');
var elpos_original = el.offset().top;
$(window).scroll(function(){
var elpos = el.offset().top;
var windowpos = $(window).scrollTop();
var finaldestination = windowpos;
var stophere = ( $('#filtering').offset().top ) - 170;
if(windowpos=stophere) {
finaldestination = elpos_original;
el.stop().animate({'top':10});
} else {
el.stop().animate({'top':finaldestination-elpos_original+10},500);
}
});