开发者

.delay() doesn' t work

开发者 https://www.devze.com 2023-03-13 05:08 出处:网络
$(\'.link\').click(function(){ $paneTarget.stop().scrollTo(\'#due\', 800, { margin: true } ).toggleClass(\'sel开发者_开发百科ected\'),
$('.link').click(function(){
    $paneTarget.stop().scrollTo('#due', 800, { margin: true } ).toggleClass('sel开发者_开发百科ected'),
    $("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?


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


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


Check the docs, you can specify a callback with onAfter

0

精彩评论

暂无评论...
验证码 换一张
取 消