JCarousel circular “no stop”

孤街浪徒 提交于 2019-12-13 00:37:49

问题


It is possible to configure JCarousel for a circular "no stop" ? I wish configure my carousel for a continuous constant circular moving. without slowing down.

Thanks


回答1:


To get it to constantly rotate you should be able to set auto:.1 and animation:5000 (or whatever speed you want. Below is an example that took me a long time to get going correctly. It is getting data through 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);
    }

Hope this helps someone. It took a while to get this working and I did a rough copy/paste here so it may take a little tweaking. If this helps, please mark it as answered.



来源:https://stackoverflow.com/questions/8747843/jcarousel-circular-no-stop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!