JQuery 动画滚动

我不知道如何调用的效果,但有人能指出我进入一个图书馆,将帮助我做同样的效果作为这个网站?

Http://www.makr.com

基本上,它可以通过鼠标单击向上移动到页面的顶部。如果没有这样的特殊效果库,代码片段(最好是 jQuery)可以提供帮助。

我不确定我是否需要开始另一个话题,但是谁能帮我用一个小的 jQuery 片段来实现 Makr UI 的整体效果?

130176 次浏览

You can animate the scrolltop of the page with jQuery.

$('html, body').animate({
scrollTop: $(".middle").offset().top
}, 2000);

See this site: http://papermashup.com/jquery-page-scrolling/

There is a jquery plugin for this. It scrolls document to a specific element, so that it would be perfectly in the middle of viewport. It also supports animation easings so that the scroll effect would look super smooth. Check out AnimatedScroll.js.

You can give this simple jQuery plugin (AnimateScroll) a whirl. It is quite easy to use.

1. Scroll to the top of the page:

$('body').animatescroll();

2. Scroll to an element with ID section-1:

$('#section-1').animatescroll({easing:'easeInOutBack'});

Disclaimer: I am the author of this plugin.

I just use:

$('body').animate({ 'scrollTop': '-=-'+<yourValueScroll>+'px' }, 2000);

var page_url = windws.location.href;
var page_id = page_url.substring(page_url.lastIndexOf("#") + 1);
if (page_id == "") {
$("html, body").animate({
scrollTop: $("#scroll-" + page_id).offset().top
}, 2000)
} else if (page_id == "") {
$("html, body").animate({
scrollTop: $("#scroll-" + page_id).offset().top
}, 2000)
}

});