2012-01-14 41 views
3

我使用下面的jQuery的顏色插件:的jQuery顏色動畫插件不工作的FF

/* 
Color animation jQuery-plugin 
http://www.bitstorm.org/jquery/color-animation/ 
Copyright 2011 Edwin Martin <[email protected]> 
Released under the MIT and GPL licenses. 
*/ 
(function(d){function i(){var b=d("script:first"),a=b.css("color"),c=false;if(/^rgba/.test(a))c=true;else try{c=a!=b.css("color","rgba(0, 0, 0, 0.5)").css("color");b.css("color",a)}catch(e){}return c}function g(b,a,c){var e="rgb"+(d.support.rgba?"a":"")+"("+parseInt(b[0]+c*(a[0]-b[0]),10)+","+parseInt(b[1]+c*(a[1]-b[1]),10)+","+parseInt(b[2]+c*(a[2]-b[2]),10);if(d.support.rgba)e+=","+(b&&a?parseFloat(b[3]+c*(a[3]-b[3])):1);e+=")";return e}function f(b){var a,c;if(a=/#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/.exec(b))c= 
[parseInt(a[1],16),parseInt(a[2],16),parseInt(a[3],16),1];else if(a=/#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/.exec(b))c=[parseInt(a[1],16)*17,parseInt(a[2],16)*17,parseInt(a[3],16)*17,1];else if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(b))c=[parseInt(a[1]),parseInt(a[2]),parseInt(a[3]),1];else if(a=/rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9\.]*)\s*\)/.exec(b))c=[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10),parseFloat(a[4])];return c} 
d.extend(true,d,{support:{rgba:i()}});var h=["color","backgroundColor","borderBottomColor","borderLeftColor","borderRightColor","borderTopColor","outlineColor"];d.each(h,function(b,a){d.fx.step[a]=function(c){if(!c.init){c.a=f(d(c.elem).css(a));c.end=f(c.end);c.init=true}c.elem.style[a]=g(c.a,c.end,c.pos)}});d.fx.step.borderColor=function(b){if(!b.init)b.end=f(b.end);var a=h.slice(2,6);d.each(a,function(c,e){b.init||(b[e]={a:f(d(b.elem).css(e))});b.elem.style[e]=g(b[e].a,b.end,b.pos)});b.init=true}})(jQuery); 

,當我嘗試使用此代碼動畫一個div:

$(".container").prepend(data.latest).find(".item_row:first").hide().slideDown().animate({backgroundColor: '#fff9a5'}).animate({backgroundColor: '#ffffff'}); 

它拋出這個錯誤螢火蟲:

b is undefined 

我甚至嘗試使用解壓縮版本,甚至使用谷歌關閉編譯它編譯應用程序沒有 運氣。

+1

提供更多信息(如HTML)會有幫助。另外,在像JSFiddle這樣的網站上重新創建問題將會很有幫助。 – 2012-01-14 16:25:45

+0

的事情是,它在jsfiddle(http://jsfiddle.net/24g9h/5/)上工作,但它不適用於我的應用程序...將檢查什麼導致這不起作用.. – fxuser 2012-01-14 16:39:57

回答

6

在動畫開始之前,應該使用此jQuery顏色插件進行動畫處理的元素必須具有背景色。用css設置:

.item_row { 
    background-color: #000000; 
} 

另請參閱此example

+0

就是這樣,謝謝! – fxuser 2012-01-14 16:42:52

+0

不客氣。 – scessor 2012-01-14 16:43:30