开发者

How do I get this scroll effect?

I just started to learn jQuery and I came across this site- TEDx Portland and I really like the scroll effect and the fact that the entire site is just one page.

Con开发者_运维知识库sidering I'm a beginner are there any resources one can point at so that I accomplish a similar effect(the smooth and eased animation)

Thanks


You can use a jQuery plugin, for example scrollTo


No plugin necessary with jQuery:

$('.scrollPage').click(function() {
   var elementClicked = $(this).attr("href");
   var destination = $(elementClicked).offset().top;
   $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination-20}, 500 );
   return false;
});

The code gets the href from the anchor and uses it as the target element. If you want to adjust the scroll speed just change the 500. Demo. Original.

And here's another tutorial.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜