jQuery的滚动,不能得到缓解工作
问题描述:
我想打一个页面的网站,一个div(导航)与固定位置和z指数999jQuery的滚动,不能得到缓解工作
的目标是使顶部的DIV和住宿所有其他内容滚动。 我得到了这个工作正常,但我想使它更“顺利”与缓和,但我尝试使脚本停止工作。这是工作脚本:
$(document).ready(function(){
$('a[href*=#]').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target
|| $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body')
.animate({scrollTop: targetOffset}, 1000) ;
return false;
}
}
});
});`
任何人都可以帮我使用缓动部分吗?我希望滚动在靠近锚点时快速启动并放慢速度。
在此先感谢。
答
更换
$('html,body') .animate({scrollTop: targetOffset}, 1000) ;
与
$('html,body') .animate({scrollTop: targetOffset}, 1000, 'easeOutQuart');
确保你已经包括jQuery UI的核心和jQuery核心作用。
+0
我看到我做错了,我在打电话给缓动js包时出现了一个错字:S真的很抱歉,家伙:S – Luuk 2011-04-04 12:34:32
建议您编辑您的帖子以格式化Javascript代码,显示正常的缩进。你有什么是真的很难阅读。 – 2011-04-04 12:08:09
对不起。完成:) – Luuk 2011-04-04 12:27:30