Hi,

I have got a sticky sidebar (created with a jquery script), and I would like it not to scroll down untill I reach the end of it...

I try to give a better explanation.
The jquery script works great if the sidebar is small... but when it start to be "longer" then it is not possible to see the bottom part of it... since it scroll down.

I would like to add to my jquery script some new command... smth like scroll down only after that i reach the end of the sidebar.

I believe i have to calculate the bottom position of the sidebar and of the window. But i don't know how exactly to do this.


This is the jQuery code

Code:
jQuery(function() {

    var jQuerysidebar = jQuery("#sidebar"),
        jQuerywindow = jQuery(window),
        offset = jQuerysidebar.offset(),
        topPadding = 15,
        stop = jQuery("#footer").offset().top;

    jQuerywindow.scroll(function() {
        if (jQuerywindow.scrollTop() > offset.top) {
            if (jQuerywindow.scrollTop() + jQuerysidebar.height() < stop) {
                jQuerysidebar.stop().animate({
                    marginTop: jQuerywindow.scrollTop() - offset.top + topPadding
                });
            }
        } else {
            jQuerysidebar.stop().animate({
                marginTop: 0
            });
        }
    });

});
Pls Help Thx!