0

I'm using the mousewheel plugin to scroll sections of my page.

What I should look into for disabling the function I wrote until the animation has fully completed?

I am running stop() but that only cancels out the animation.

$('section').mousewheel(function(event, delta, deltaX, deltaY) {

$('section' ).waypoint(function(direction){
    thisID = $(this); 
},{ offset: '25%' });

if (delta > 0) {
    console.log('up');
    if ($(this).not(":first-child")) { 
        //$(this).animate(function(){
        $('html, body').stop().animate({
            scrollTop: thisID.prev().offset().top
        }, 1000);
            //});
    }else {
        $('html, body').stop().animate({
            scrollTop: thisID.offset().top
        }, 1000);
    }
    }
else if (delta < 0) {

    if ($(this).not(":first-child")) { 
        $('html, body').stop().animate({
            scrollTop: thisID.next().offset().top
        }, 1000);
    }
    else {
        $('html, body').stop().animate({
            scrollTop: thisID.offset().top
        }, 1000);
    }

    console.log('down');
}
return false; // prevent default
});
4

2 回答 2

2

一种方法是创建一个“红绿灯”变量。将其设置为函数的开头,然后使用函数的参数False将其重新设置为True动画的结尾。然后使 main 函数仅在此变量为 时运行。completeanimate()True

于 2013-08-13T18:49:08.293 回答
0

您可能不想重新发明轮子,而是想看看诸如fullPage.js 之类的东西。

当您开始处理触摸设备、触摸屏、旧浏览器、触控板或 Apple 笔记本电脑中存在的动态滚动时,它将使您免于许多麻烦……

于 2015-04-07T15:59:00.520 回答