2014-02-11 22 views
0

我有一個數組,包含4個jQuery元素。Animate數組元素,同時改變索引

<div class="wrapper"> 
<img class="image"> 
<img class="image"> 
<img class="image"> 
<img class="image"> 
</div> 

在jQuery中:

var images = $('.image'); 

對於我的幻燈片效果(例如在左側的幻燈片)我做了類似的東西(這不是我的完整代碼,滑動效果的作品!)

$('.wrapper').prepend($('.image').last()); 
$('.wrapper').css('margin-left', '0px'); 
$('.wrapper').animate({'margin-left', '-100px'}, 1000); 

我的包裝向左滑動。現在,我想在幻燈片上轉換我的圖像。

if(images.index() === 0) { 
    // some css for this image (I do my transformation width css transition) 
} else if(images.index() === 1) { 
    // do some other transformation with css 
} 

我認爲包括裏面ifanimate()的(目前,內complete)。

所以我的包裝向左滑動,我的數組元素轉換爲他們應該但只在幻燈片動畫結束。我需要這個轉換,而我的幻燈片效果。

像:

while(images.index() >= 0 && images.index() <= 1) {// do transformation while this is true} 
+0

我查用prepend和append來修飾我的數組。我需要時間追加或預先考慮。 Thx – mkoehler

+1

你嘗試過什麼嗎? –

+0

不,我不知道什麼時候需要動畫我的數組元素。我的元素'two'從位置2滑到1.雖然這個過程我想轉換這個元素。 – mkoehler

回答