Aeonius
Aeonius

Reputation: 1073

.delay() doesn' t work

$('.link').click(function(){
    $paneTarget.stop().scrollTo('#due', 800, { margin: true } ).toggleClass('selected'),
    $("body").delay(1000).animate({backgroundColor: "#1c6e7a"},800);   

});

The delay function doesn't work in the example. If I remove the .delay value the code works, but I need the background to change AFTER the other function has completed. Any suggestions?

Upvotes: 0

Views: 400

Answers (3)

Mark Coleman
Mark Coleman

Reputation: 40863

I am assuming this is the .scrollTo() plugin. The plugin allows for a call back after the animation completes.

onAfter: A function to be called after the whole animation ended.

$('.link').click(function () {
    $paneTarget.stop().scrollTo('#due', 800, {
        margin: true,
        onAfter: function () {
            $("body").animate({
                backgroundColor: "#1c6e7a"
            }, 800);
        }
    }).toggleClass('selected');
});

Example on jsfiddle

Upvotes: 4

Karoly Horvath
Karoly Horvath

Reputation: 96258

Check the docs, you can specify a callback with onAfter

Upvotes: 0

Bernardo Mendes
Bernardo Mendes

Reputation: 1220

I googled about it and i think that backgroundColor cant be animated for that you will need the jQuery plugin color:

http://plugins.jquery.com/project/color

Upvotes: 0

Related Questions