滚动jquery时跟随导航栏

i have a jquery for the bar following when scroll down/up but it has delay CSS

#rightbar_scroll {position: absolute;top: 0;right: 0;z-index: 10000; }

 jQuery(document).ready(function(){
    var jQuerysidebar   = jQuery("#rightbar_scroll"),
        jQuerywindow    = jQuery(window),
        offset     = jQuerysidebar.offset(),
        topPadding = 20;
    jQuerywindow.scroll(function() {
        if (jQuerywindow.scrollTop() > offset.top) {
            jQuerysidebar.stop().animate({
                marginTop: jQuerywindow.scrollTop() - offset.top + topPadding
            });
        } else {
            jQuerysidebar.stop().animate({
                marginTop: 0
            });
        }
    });
});

i want it no delay, how do i add position like the box "Similar Questions" at the right side when ask question in this site?

Thank you, sorry my English not good

Try to use jQuery.css() instead jQuery.animate()

jQuerysidebar.css({
    marginTop: jQuerywindow.scrollTop() - offset.top + topPadding
});

Change the position of #rightbar_scroll to fixed, if the page is scrolled >= offset.top And don't forget to change it back to absolute, if the page is scrolled back again...