Grow your CSS skills. Land your dream job.

How to callback properly? (and timeout)

  • # January 22, 2009 at 8:19 am

    Hi all,

    I’m having some trouble understanding how the callback works. This is a quite simple example, doesn’t work as I want it to though. My idea is that box2 should animate back when the two first (and simoltaneous, spelling) animations complete, however it doesn’t.

    Another question is how will I delay the callback by say two seconds? And is it possible to loop this over and over again?

    Code:
    $(‘#elevator’).click(function(){
    $(‘#box1′).animate({width: 250, height: 300}, 1000);
    $(‘#box2′).animate({width: 200, height: 300}, 1000);
    }, function(){
    $(‘#box2′).animate({width: 300, height: 10}, 1000);
    }
    );
    # January 22, 2009 at 10:47 pm

    I wouldn’t even class myself a beginner with jQuery, thats why I always look at the documentation.

    Go to their site and search those specific terms (call backs, delays, queue), study all there examples carefully. I know everytime I have a problem, I always use this process.

    Hope this helps in some indirect way.

    Rob
    # January 23, 2009 at 2:31 pm

    you could try this…

    Code:
    $(‘#elevator’).click(function(){
    $(‘#box1′).animate({width: 250, height: 300}, 1000);
    $(‘#box2′).animate({width: 200, height: 300}, 1000)
    .animate({width: 300, height: 10}, 1000);
    }
    );

    bit of a random guess tbh lol

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".