tags:

views:

218

answers:

2

hi,

i want to position a banner while scrolling

the code is

$(window).scroll(function(){
    offset = $(window).scrollTop()+80;
    var h = $(window).height();

    if(offset < 80 && offset < (h-800))
    {
        offset = 80;
    }

    $('#sidebar1').animate({top:offset}, 450);
});

the problem is the offset is dynamic and it changes while scrolling down, the banner goes beyond the window and while scrolling down it slides up slowly. i want a constant animation while scrolling up and down. i dont thing there is a attribute like bottom instead of top or is their event other than scroll to acheive it

Any help will be much appreciated

A: 

Here is a interessting thread regarding your question answered by Chris Hanscom - Microsoft MVP:

Microsoft Forums

Mentioned in this thread...an nice small Plugin for jquery for scrolling in all available directions: JScroller

Hope this helps...

bastianneu
A: 

See this link - http://net.tutsplus.com/tutorials/html-css-techniques/creating-a-floating-html-menu-using-jquery-and-css/

I also asked a question around this topic a while ago which may be useful to you. It is a modified version of the above example - http://stackoverflow.com/questions/1914550/floating-scrolling-div-with-vertical-constraints

If this isn't what you're after, perhaps you could provide more of an explanation of your problem, perhaps which screenshots or even an example website.

Rezler