【发布时间】:2014-03-12 12:34:38
【问题描述】:
我正在尝试创建一个脚本,该脚本可以在不使用插件的情况下为页面上的部分之间的滚动设置动画 - 只是纯 jquery。但是,当我尝试滚动页面时,似乎遇到了一些问题。谁能帮帮我?
这是我的jsFiddle 还有我的代码:
$(document).ready(function() {
$('.main').bind('mousewheel', function(e){
var mHeight=$(document).height()/8;
console.log(mHeight);
if(e.originalEvent.wheelDelta /120 > 0) {
// alert('up');
$('html, body').animate({
scrollTop: mHeight
}, 1000);
}
else{
// alert('down');
$('html body').animate({
scrollTop: -mHeight
}, 1000);
}
});
});
【问题讨论】:
-
@AnoopJoshi 我想在部分之间设置动画和滚动,而不是在类似 alvarotrigo.com/fullPage 但没有插件的部分之间滚动
标签: javascript jquery scroll jquery-animate