How to sort animations with jQuery?

5

I have this code and wanted to sort the animations, so that the header only starts after the .logo_1 ends. I tried to use duration but it did not work, is there any other way I can sort animations?

$(document).ready(function(e) {
    $('.mini_botao').click(function(){
        $(".logo_1").animate({marginTop: '-150px'}, 1000);
        $("header").animate({marginTop: '0'}, 3000);
    });
});
    
asked by anonymous 09.04.2014 / 04:50

2 answers

4

Try a delay before

$("header").delay(2500).animate({marginTop: '0'}, 1000);

References:

09.04.2014 / 05:22
6

Add a callback in the first animation, then use the second.

$(document).ready(function(e) {
    $('.mini_botao').click(function(){
        $(".logo_1").animate({marginTop: '-150px'}, 1000, function() {
            $("header").animate({marginTop: '0'}, 1000);
        });
    });
});
    
09.04.2014 / 05:10