I\'m currently using the following:
http://jsfiddle.net/0mLzseby/469/
To make my sidebar follow down the page. I have quite a large footer though and I\'d li
You forgot to add class, if we are in the footer, and refrech the page, then, the sidebar won't show :
function sticky_relocate() {
var window_top = $(window).scrollTop();
var footer_top = $("#footer").offset().top;
var div_top = $('#sticky-anchor').offset().top;
var div_height = $("#sticky").height();
var padding = 20; // tweak here or get from margins etc
if (window_top + div_height > footer_top - padding) {
$('#sticky').addClass('stick'); //////// here is to get fixed when we refrech page when we are in the footer
$('#sticky').css({top: (window_top + div_height - footer_top + padding) * -1})
} else if (window_top > div_top) {
$('#sticky').addClass('stick');
$('#sticky').css({top: 0})
} else {
$('#sticky').removeClass('stick');
}
}