views:

26

answers:

2

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(':animated')) {
    list.animate(
        {"top": "+="+item_size},
        {queue:false, duration:speed},
        function() {
            alert();
        }
    ); // end of animate function

} //end of if statement
+2  A: 

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
lonesomeday
*hits head on wall* Thanks so much for this! I'm a newbie as of yesterday - can you tell? :P
hugh jackson
@hugh We've all been there! If this answer has answered your question, you can mark it by clicking the empty tick to the left of the answer.
lonesomeday
You've been ticked ;) Thanks mate
hugh jackson
A: 

Check the API, you don't seem to be calling the funtion 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.

mdrg
Thankyou so much! I solved the problem a moment before these two posts by just removing the {queue: false, duration: speed} and replacing it with speed, but its great to know how I can include this parameter if i need to.
hugh jackson