Matt
Matt

Reputation: 105

Why is this JQuery animation jumpy?

I am trying to animate an image slowly, but it's just jumping suddenly after the delay, not actually sliding over. Any idea why?

$(document).ready(function() {
    $('#Picture').fadeIn(1000).delay(1500).animate({'top': '25px', 'left': '20px', 'height': '101px'},2000);
});

Upvotes: 0

Views: 667

Answers (1)

unclenorton
unclenorton

Reputation: 1625

Try using callback function:

$(document).ready(function() {
    $('#Picture').fadeIn(1000, function(){
        $(this).delay(500).animate({'top': '25px', 'left': '20px', 'height': '101px'},2000);
    });
});

The anonymous function will be executed after fadeIn is complete.

UPD: No sleep function, changed to delay. Example here: http://jsfiddle.net/CbgzG/

UPD2: OP's code works just as well: http://jsfiddle.net/CbgzG/1/

Upvotes: 1

Related Questions