2010-04-20 89 views
2

我在#next #prev導航和圖像計數器輸出的幾個圖庫中使用jQuery循環。jQuery Cycle - #next #prev,在currentGallery的最終幻燈片後轉到nextGallery

現在我試圖將所有這些畫廊連接在一起。如果用戶到達圖庫A(galleryA.html)的最後一張幻燈片,則#next錨點應該指向圖庫B(galleryB.html)/ #prev錨點應該指向圖庫C(galleryC.html)。

如何結合我的2個功能來做到這一點?

 
// slideshow fx 
$(function() { 
     $('#slideshow').cycle({ 
     fx:  'fade', 
     speed: 350,   
     prev: '#prev', 
     next: '#next', 
     timeout: 0, 
     after:  onAfter 
    }); 
}); 
//image counter output 
function onAfter(curr,next,opts) { 
    var caption = 
     (opts.currSlide + 1) + opts.slideCount; 
     $('#counter').html(caption); 
} 

HTML:

<div id="slideshow-container"> 

<div class="slideshow-nav"><a id="prev" href=""></a></div> 
<div class="slideshow-nav"><a id="next" href=""></a></div> 

<div id="slideshow" class="pics"> 
    <img src="galleryA/01.jpg" /> 
    <img src="galleryA/02.jpg" /> 
    <img src="galleryA/03.jpg" /> 
    <img src="galleryA/04.jpg" /> 
    <img src="galleryA/05.jpg" /> 
    <img src="galleryA/06.jpg" /> 
</div> 
</div> 

回答

1

不太熟悉的週期插件,但你可以把這樣的事情在function onAfter

if(opts.currSlide == opts.slideCount) { 
    $("#next").attr("href","galleryB.html"); 
} 

或者你可以嘗試

if(opts.currSlide == opts.slideCount) { 
$("#next").click(function() { document.location = "galleryB.html"; }); 
} 

Untes特德,這些線?

基本上它只在最後一張幻燈片顯示後纔將重定向行爲附加到#next上。可能有onFinish選項或者其他什麼,你檢查過文檔嗎?

+0

感謝您的提示。我會嘗試所有可能的方式,我可以提出。 jQuery的週期設有一個結束選項: 結束日期null,//調用的回調時,幻燈片終止(帶自動停止或NOWRAP選項使用):功能(選擇) 我想我的麻煩,因爲我試圖旋轉withing圖像組和畫廊,所以#prev和#next錨點做兩件事,在一組圖片中旋轉,當到達最後(在任何一邊!)將轉到下一個或prev畫廊。 – FHP 2010-04-20 13:06:38

0

你可以看看這裏:

http://helpdesk.toitl.com/?p=cycle_plugin

它不那麼容易2個同步週期在同一個頁面整合......在此示例中不存在與位置頁面重載= ...但是2個畫廊是使用循環插件的不同命令進行管理的。

Regards, Dominique VINCENT

+0

聖...!非常感謝您的努力和時間。我需要幾天才能理解所有內容:-O 我真的需要得到你的JS技能...... – FHP 2010-04-24 15:52:37