2012-01-05 46 views
1

有可能配置JCarousel爲「不停」通告?我希望配置我的傳送帶連續不斷的循環移動。沒有減慢。JCarousel通告「不停」

感謝

+0

jCarousel有[已知的長期問題](http s://github.com/jsor/jcarousel/issues/search?q = circular)和'wrap circular'。不建議您在開發人員修復插件之前使用它。 – Sparky 2012-01-05 18:37:46

+0

查看[Infinite Carousel](http://www.catchmyfame.com/catchmyfame-jquery-plugins/jquery-infinite-carousel-plugin/)。所有的例子都是無限的,但第五個演示不斷運行。 – j08691 2012-01-09 20:55:05

回答

1

爲了得到它不斷旋轉您應該能夠設置自動:.1和動畫:5000(或任何你想要的速度下面是我花了很長時間纔去正確的例子它是通過jQuery的AJAX獲取數據。

var lis; //Global variable holding the data. 
    var myCarousel01; //Global variable holding the carousel. 

    $(document).ready(function() { 
     updateData(); 

     $("#tableapp").ajaxStop(function() { 
       InitiateCarousels(); 
      } 

      rebindCarousels(); 
     }); 

    }); 

    function updateData() { 
     $.get('AjaxPages/ApplicationMonitor.aspx', function (data) { 
      lis = $(data).find("li"); 
     }); 
    } 

function InitiateCarousels() { 
jQuery('#mycarousel1').jcarousel({ 
    wrap: 'circular', 
    auto:.1, //Amount of time you want slide to stop in seconds 
    animation:5000, //Desired speed in milliseconds 
    easing:"linear", //Prevents the slides from "slowing down" 
    initCallback: myCarousel01_initCallback, 
    itemFirstInCallback: myCarousel01_itemFirstInCallback 
}); 
}); 

function myCarousel01_initCallback(carousel, state) { 
    if (state == "init") { 
     myCarousel01 = carousel; //Bind carousel to global variable so you can retrieve it later. 
    } 
} 


    function rebindCarousels() { //This function gets called after data is binded to the lis variable. See: "ajaxStop" function above. 
     //Rebind Carousel01 
     myCarousel01.list.empty(); 
     $.each(lis, function (i, l) { 
      myCarousel01.add(i + 1, l); 
     }); 
     myCarousel01.size(lis.length); 
    } 

希望這可以幫助別人。過了一段時間得到這個工作,我做了一個粗略的複製/粘貼這裏,所以它可能需要一些調整。如果有幫助,請標記爲已回答。