2013-10-10 38 views
0

沒有任何運氣可以改變幻燈片在fotorama中的時間間隔(時間)。我可以更改過渡時間,但不能更改圖像/幻燈片之間的持續時間。我試着改變data-autoplay =「3000」的間隔,但它沒有做我想要的。這裏是我的代碼:如何減慢或加快jQuery fotorama中幻燈片之間的時間間隔

+0

也許向我們展示你的代碼,以便我們更好地瞭解你在做什麼。 – Jared

回答

-1

數據過渡時間=「1000」

0

不知道這是你在找什麼?我還提供了 How can I set different duration for each fotorama/slide? (not transition duration)

該解決方案

如果要更改時間顯示下一張幻燈片之前,對於個人幻燈片......我處理這種方式,通過聽取fotorama.showend事件:

在你的基地JS腳本,包括這一點。 ..我沒有'不會在包含多個照片的頁面上對其進行測試,因此它可能會影響頁面上的所有內容,並且您必須修改這些變量才能定位特定的影音。

$(function() { 
    $('.fotorama') 
     /* Listen to the "showend" event... the "show" event is for the beginning of a transition, while "showend" is at the end of the transition. */ 
     .on('fotorama:showend', 
      function (e, fotorama, extra) { 
       /* do a switch on the active index + 1, if you want the current frame at base 1 instead of base 0 */ 
       switch (fotorama.activeIndex + 1){ 
        case 2: 
         fotorama.setOptions({autoplay: 3000}); 
         break; 
        case 5: 
         fotorama.setOptions({autoplay: 15000}); 
         break; 
        case 6: 
         fotorama.setOptions({autoplay: 7000}); 
         break; 
        case 7: 
         fotorama.setOptions({autoplay: 20000}); 
         break; 
        case 8: 
         fotorama.setOptions({autoplay: 2000}); 
         break; 
        default: 
         /* You could choose to always set the autoplay to a default value here as shown, but it may be more efficient to just always set it back to default on the first slide of a "default duration" sequence (above ex. slide 2 of slides 2-4, or slide 8 of slides 8-the end), instead of setting a new autoplay value on each and every slide regardless of whether or not it's needed. */ 
         fotorama.setOptions({autoplay: 2000}); 
         break; 
       } 

       /* see the event fire in developer console, for debugging only */ 
       console.log('## ' + e.type); 
       console.log('active frame', fotorama.activeFrame); 
       console.log('additional data', extra); 
      } 
     ) 
    }); 

重要的是要認識到,「show」和「showend」事件是幻燈片專用的,而不是幻燈片專用的。

如果您希望在某些幻燈片結束後更改其他屬性,例如從交叉淡入淡出切換到幻燈片過渡,或者加快或減慢過渡持續時間,這也很方便。

如果你想在一個轉變的開始在一些事情上採取行動,聽「fotorama:秀」 ......事件的完整列表來聽,用控制檯調試代碼從API page

$(function() { 
    $('.fotorama') 
     // Listen to the events 
     .on('fotorama:ready ' +   // Fotorama is fully ready 
      'fotorama:show ' +   // Start of transition to the new frame 
      'fotorama:showend ' +   // End of the show transition 
      'fotorama:load ' +   // Stage image of some frame is loaded 
      'fotorama:error ' +   // Stage image of some frame is broken 
      'fotorama:startautoplay ' + // Slideshow is started 
      'fotorama:stopautoplay ' + // Slideshow is stopped 
      'fotorama:fullscreenenter ' + // Fotorama is fullscreened 
      'fotorama:fullscreenexit ' + // Fotorama is unfullscreened 
      'fotorama:loadvideo ' +  // Video iframe is loaded 
      'fotorama:unloadvideo',  // Video iframe is removed 
      function (e, fotorama, extra) { 
       console.log('## ' + e.type); 
       console.log('active frame', fotorama.activeFrame); 
       console.log('additional data', extra); 
      } 
     ) 
     // Initialize fotorama manually 
     .fotorama(); 
    }); 
相關問題