开发者

anonymous callback function in .animate() not working

开发者 https://www.devze.com 2023-01-21 06:27 出处:网络
I can\'t for the life of me figure out what the problem with this code is.The animation itself works fine:

I can't for the life of me figure out what the problem with this code is. The animation itself works fine:

if (!list.is(':a开发者_运维问答nimated')) {
    list.animate(
        {"top": "+="+item_size},
        {queue:false, duration:speed},
        function() {
            alert();
        }
    ); // end of animate function

} //end of if statement


You're mixing up the two signatures of .animate(). You need to make the callback a part of the options argument:

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


Check the API, you don't seem to be calling the function right:

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

Guess this is how you should call it:

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

Change linear to whatever easing function you need.

0

精彩评论

暂无评论...
验证码 换一张
取 消