0

我使用jCarousel来做类似的事情: Carousel with autoscrolling但我做不到。

我创建了一个custom.js文件来添加我所有的 js。对于jCarousel部分,我使用了以下代码:

$(function() {

    $.fn.startCarousel = function() {
        var bodywidth = $('body').width(),
            itemwidth = $('.mycarousel li').outerWidth(true),       
            mycontwidth = bodywidth > itemwidth ? bodywidth - bodywidth%itemwidth : itemwidth,
            licount = $('.mycarousel li').size(),
            jscroll = 1;

        if(licount > mycontwidth/itemwidth){
            jscroll =  mycontwidth/itemwidth;
        } else {
            jscroll = 0;
            mycontwidth = licount * itemwidth;
        }

        $('.mycont').width(mycontwidth);

        $('.mycarousel').jcarousel({
            scroll:jscroll
        });
    };

    $(this).startCarousel();

    $(window).resize(function(){
        $(this).startCarousel();
    }); 
    var carousel = $('.mycarousel');
    $(carousel).jcarousel({
        scroll:1,
        wrap: 'circular'
    });

    carousel.touchwipe({
        wipeLeft: function() {
            carousel.jcarousel('next');
        },
        wipeRight: function() {
            carousel.jcarousel('prev');
        }
    });

});

我也试过:

var carousel = $('.mycarousel');
$(carousel).jcarousel({
    auto:2,
    scroll:1,
    wrap: 'last'
});

或者wrap: 'circular',但这也不起作用。

感谢您的任何帮助!

4

1 回答 1

0

尝试这个:

<script>


$(function() {
    $("#carouselContainerIDhere").jCarouselLite({
        btnNext: "#carouselContainerIDhere .next",
        btnPrev: "#carouselContainerIDhere .prev",
        speed: 500,
        auto: boo
    });    
});
var boo = "true";
if($content.boo.value)
    boo = $content.boo.value;
</script>
于 2013-09-16T10:42:58.120 回答