2012-11-29 44 views
0

我想:自動播放:與jQuery flowslideshow真當窗口被調整大小

自動播放:假是在窗口的大小和寬度> 900時,

自動播放:真時是寬度寬度> 701在窗口的大小和,

自動播放:假時是寬度< 701在窗口尺寸

與jQuery flowslideshow並且當窗口大小運行該代碼

但不工作。

$(window).resize(function() { 
var width = $(window).width(); 
if (width > 900) { 
    $(function() { 
     $(".slidetabs").tabs(".images > div", { 
      // enable "cross-fading" effect 
      effect: 'fade', 
      fadeOutSpeed: "slow", 
      // start from the beginning after the last tab 
      rotate: true, 
      showMultiple: 5 
      // use the slideshow plugin. It accepts its own configuration 
     }).slideshow({ **autoplay: false**, clickable: false }); 
    }); 
} 
else if (width < 900 & width > 701) { 
    $(function() { 
     $(".slidetabs").tabs(".images > div", { 
      // enable "cross-fading" effect 
      effect: 'fade', 
      fadeOutSpeed: "slow", 
      // start from the beginning after the last tab 
      rotate: true, 
      showMultiple: 5 
      // use the slideshow plugin. It accepts its own configuration 
     }).slideshow({ **autoplay: true**, clickable: false }); 
    }); 
} 
else (width < 701) 
{ 
    $(function() { 
     $(".slidetabs").tabs(".images > div", { 
      // enable "cross-fading" effect 
      effect: 'fade', 
      fadeOutSpeed: "slow", 
      // start from the beginning after the last tab 
      rotate: true, 
      showMultiple: 5 
      // use the slideshow plugin. It accepts its own configuration 
     }).slideshow({ **autoplay: false**, clickable: false }); 
    }); 
} }); 

回答

0

窗口並不總是火在頁面加載,所以幻燈片不會在這種情況下自動播放的事件的onResize。它does appear to fire on page load in ie9。另外,這個代碼會在每次調整頁面大小時重新創建幻燈片 - 這可能不是您想要的。

您可能會更好地綁定頁面加載的幻燈片,然後綁定事件來調整大小以暫停/恢復滑動行爲。就像這樣:

jQuery(function($) { 
    // detect window size and init slideshow here 
    $(window).on('resize', function() { 
     // detect window size and pause or resume the slideshow 
    }); 
}); 

沒有看到的文檔爲你使用我不能指向你的確切方向它的初始化後,如何修改幻燈片播放幻燈片,但如果你按照它應該是可能的上述原則。

(在一個側面說明,檢查resize事件被正確觸發,你可以console.log($(window).width())

如果您需要更多的幫助,可以考慮張貼Fiddle在它的完整的例子,並鏈接到文檔爲您使用的幻燈片插件。

相關問題