4

我一生都无法弄清楚这段代码有什么问题。动画本身工作正常:

if (!list.is(':animated')) {
    list.animate(
        {"top": "+="+item_size},
        {queue:false, duration:speed},
        function() {
            alert();
        }
    ); // end of animate function

} //end of if statement
4

2 回答 2

5

您正在混淆 . 的两个签名.animate()。您需要使回调成为options参数的一部分:

if(!list.is(':animated')){
    list.animate({
        top: "+="+item_size
    }, //end of properties argument
    {
        queue: false, 
        duration: speed,
        complete: function(){
            alert();
        } //end of callback
    }  // end of options argument
    ); // end of animate function
} //end of if statement
于 2010-10-26T15:32:01.770 回答
1

检查API,您似乎没有正确调用该函数:

.animate( properties, [ duration ], [ easing ], [ callback ] )

猜猜你应该这样称呼它:

.animate( {"top": "+="+item_size}, speed, 'linear', function(){alert();});

更改linear为您需要的任何缓动功能。

于 2010-10-26T15:32:30.417 回答