0

The Situation:

I have a pretty regular sidebar on my website.

As the last element in the sidebar you can see the Blogroll.

Below this I need to create a similar container which only contains a scroll-to-top button.

Pretty easy so far.


The Problem:

I need the Button to behave the following way:

  • If you scroll down and this container (only this) approaches the upper edge of the visible area I need it to stay there (position:fixed?) and move down with you. (With a little offset to the top)

  • If the you scroll up again it moves up with you. But it has to stop when it gets to its old position.

  • It needs to stop before the footer begins.


How far am I?

I know a bit of jquery but am no master.

Is such a thing actually possible?

I am happy to attach special classes to the container to make it work. At the moment I am just not sure how to approach this.

Any Ideas?

Arrowcatch
  • 1,612
  • 3
  • 19
  • 26
  • I'm not sure about the availability of plugins, but I have seen such behaviours implemented in many sites. You need to keep track of a few variables. First is the [scrollTop](http://jqapi.com/#p=scrollTop) to find where the page is scrolling vertically, second is the position of the button via [offset](http://jqapi.com/#p=offset). Keeping track of these 2 variables using page [scroll](http://jqapi.com/#p=scroll) will help you to determine when to set the css attributes of the button. You'll need to change the css `position` to and from `fixed` with proper offset. – VKen Mar 15 '13 at 00:32
  • You are most welcomed. – VKen Mar 17 '13 at 04:01

0 Answers0