2011-07-23 4 views
4

私はfadeIn(不透明度トグル)とボーダーフェード(jquery-animate-colorsを使用)を同時に発生させようとしていますが、何か問題があります。誰かが次のコードを見直すのを助けることができるか同時jQueryアニメーション

$.fn.extend({ 
    key_fadeIn: function() { 
    return $(this).animate({ 
     opacity: "1" 
    }, 600); 
    }, 
    key_fadeOut: function() { 
    return $(this).animate({ 
     opacity: "0.4" 
    }, 600); 
    } 
}); 

fadeUnselected = function(row) { 
    $("#bar > div").filter(function() { 
    return $(this).id !== row; 
    }).key_fadeOut(); 
    return $(row).key_fadeIn(); 
}; 

highlightRow = function(row, count) { 
    return $(row).animate({ 
    "border-color": "#3737A2" 
    }).animate({ 
    "border-color": "#FFFFFF" 
    }).animate({ 
    "border-color": "#3737A2" 
    }).animate({ 
    "border-color": "#FFFFFF" 
    }); 
}; 


fadeUnselected("#foo"); 
highlightRow("#foo"); // doesn't fire until fadeUnselected is complete 

本当にありがとう。ありがとう!

+0

あなたは、このようなjsfiddle.net上として、デモを提供することができればいいだろう – karim79

答えて

9

デフォルトでは、JQueryはエフェクトキューにアニメーションを配置します。アニメーションをすぐに実行したい場合は、アニメーションオプションマップのqueue:falseフラグを設定します。例えば

は、あなたのケースでは、

$(this).animate({ 
     opacity: "1" 
    }, 600); 

は、あなたはおそらくオプションのマップを使用し、同様に国境アニメーション用のキューを設定したいと思います

$(this).animate(
{ 
    opacity: "1" 
}, 
{ 
    duration:600, 
    queue:false 
}); 

なります。

http://api.jquery.com/animate/

0
$.fn.extend({ 
    key_fadeIn: function() { 
    return $(this).animate({ 
     opacity: "1" 
    }, { duration:600, queue:false }); 
    }, 
    key_fadeOut: function() { 
    return $(this).animate({ 
     opacity: "0.4" 
    }, { duration:600, queue:false }); 
    } 
}); 

fadeUnselected = function(row) { 
    $("#bar > div").filter(function() { 
    return $(this).id !== row; 
    }).key_fadeOut(); 
    return $(row).key_fadeIn(); 
}; 

highlightRow = function(row, count) { 
    return $(row).animate({ 
    "border-color": "#3737A2" 
    }).animate({ 
    "border-color": "#FFFFFF" 
    }).animate({ 
    "border-color": "#3737A2" 
    }).animate({ 
    "border-color": "#FFFFFF" 
    }); 
}; 
関連する問題