views:

695

answers:

1

Facebook has a nice scroll effect which I would like to replicate with jQuery. When you load a page it starts at the top then scrolls to the selected anchor.

I've tried doing this (page.html#anchor) and using the scrolling plugin for jQuery however it just goes straight to that anchor without using the scroll effect.

So can I delay the scroll when the page is loaded then use jQuery to do the scrolling instead?

I apologise if I have explained it badly.

+5  A: 

http://www.learningjquery.com/2007/09/animated-scrolling-with-jquery-12

basically, you're going to want to animate the scrollTop CSS property.

$(document).animate({scrollTop: AMOUNT}, 1000);
mikeycgto
But when I load the page it scrolls straight to that element. I want it to wait until the page loads then animate the scroll.
Ben Shelock
just wrap that in a $(document).ready(function() { [code]});Could also bind it to any other event really. The possibilities are limitless.
mikeycgto