2016-03-27 38 views
-2

我必須爲數組編寫動畫。每個盒子,一個接一個,會在3000毫秒內變成白色。但它不起作用。你可以幫我嗎?我無法及時限制javascript動畫

function searchNumber(){ 
    var taille; 
    for(var i=0; i<taille; i++) { 
     tabRect[i].hide("5000"); 
     tabRect[i].show(); 
    } 
} 
+3

請你想要的動畫序列是用什麼詞形容。從目前的問題來看,這並不完全清楚。另外,由於'taille'沒有被定義,它不會在你的for循環中工作。並且,請顯示'tabRect'是什麼。 – jfriend00

+0

感謝您的支持!動畫應顯示數組中的所有值將被逐一處理(我們正在搜索選擇排序的最大值)。 ** taille **是陣列的大小。 ** tabRect **是一組元素「forme」,定義如下:' 'forme = paper.rect(400,this.y,50,50).attr({fill:color})。animate(animIntroCase (this.x));' 如果不清楚,我很抱歉。請告訴我,如果我應該把所有的代碼。再次感謝你。 –

+0

本網站的工作方式是,您應該使用「編輯」鏈接,並直接向您的問題添加附加說明。人們不應該閱讀評論來理解你的問題。你的問題應該完全清楚。你對你的問題感到低落的原因是它不清楚。 – jfriend00

回答

0

您可以CSS3做到這一點,是沒有必要的的JavaScript爲:

https://jsfiddle.net/rzcdqh8k/

.animation { 
    width: 100px; 
    height: 100px; 
    background-color: red; //original color 
    -webkit-animation-name: example; 
    -webkit-animation-duration: 3s; 
    -webkit-animation-iteration-count: infinite; 
    animation-name: example; 
    animation-duration: 3s; 
    animation-iteration-count: infinite; 
} 

/* Chrome, Safari, Opera */ 
@-webkit-keyframes example { 
    from {background-color: red;} //original color 
    to {background-color: white;} 
} 

/* Standard syntax */ 
@keyframes example { 
    from {background-color: red;} //original color 
    to {background-color: white;} 
}