2013-05-18 65 views
0

我正在使用鼓室彈簧片旋轉木馬響應式jQuery插件爲我的網站。該插件完美地在我的網站上運行。但是,我希望這個賭場能夠自動播放。Tympanus Elastislide Carousel自動播放

但是,我沒有找到自動移動傳送帶的任何代碼。

的滑塊插件鏈接:http://tympanus.net/codrops/2011/09/12/elastislide-responsive-carousel/

的Java腳本,我使用

<script type="text/javascript"> 

    $('#carousel').elastislide({ 

    // orientation 'horizontal' || 'vertical' 
    orientation : 'horizontal', 

    // sliding speed 
    speed : 500, 

    // sliding easing 
    easing : 'ease-in-out', 

    // the minimum number of items to show. 
    // when we resize the window, this will make sure minItems are always shown 
    // (unless of course minItems is higher than the total number of elements) 
    minItems : 3, 

    // index of the current item (left most item of the carousel) 
    start : 0, 

    // click item callback 
    onClick : function(el, position, evt) { return false; }, 
    onReady : function() { return true; }, 
    onBeforeSlide : function() { return false; }, 
    onAfterSlide : function() { return false; } 

    });    

</script> 

任何一個可以幫助如何滑塊機器會自動播放?我試過自動播放:是的。但是,不工作。

回答

1

嘗試滾動特性,

scroll: 1 

你可以找到你的答案在這裏,因爲

http://sorgalla.com/jcarousel/

也是所有類型的旋轉木馬滑塊看到這些

http://sorgalla.com/projects/jcarousel/examples/static_auto.html

+0

我試着用滾動:1 但是,不能正常工作。 –

+0

看到第一個鏈接,它會給出所有的輪播類型,看演示你可以找到你想要的滑塊。 –

+0

你好滑動js文件中沒有自動滾動屬性,請嘗試其他自動滾動滑塊。 –

6

下面是一個類似的問題修正的應答: How to modify Elastislide so it loops infinitely

這將使Elastislide自動播放,並當上了最後一張幻燈片,將返回到第一張幻燈片。

添加以下代碼到$.Elastislide.defaults對象start : 0,後:

// autoplay true || false 
autoplay : true, 

然後您就必須設置autoplay值(true或false)當您設置的選項了,因爲你的能力試圖在上面的示例代碼中做。

此代碼應在_initEvents功能被添加VAR後self = this;

 if(this.options.autoplay == true){ 
      var translation = 0; 
      // width/height of an item (<li>) 
      var itemSpace = this.options.orientation === 'horizontal' ? this.$items.outerWidth(true) : this.$items.outerHeight(true); 
      // total width/height of the <ul> 
      var totalSpace = this.itemsCount * itemSpace; 
      // visible width/height 
      var visibleSpace = this.options.orientation === 'horizontal' ? this.$carousel.width() : this.$carousel.height(); 
      //slide auto 
      window.setInterval(function(){ 
       //test if we should go to next slide or return to first slide 
       if(totalSpace > translation + visibleSpace) 
       { 
        //go to next slide 
        self._slide('next'); 
        //update translation 
        translation += visibleSpace; 
       } 
       else 
       { 
        //return to first slide 
        self._slideTo(0); 
        //set translation to 0 
        translation = 0; 
       } 
      }, 7000); 
     } 

要知道,作爲Elastislide演變過去V1.1.0該代碼可能不會在將來版本。

+0

不錯的一個。最佳答案 – Dslayer