jCarousel不断在最后添加新项目

时间:2013-02-12 23:03:06

标签: javascript jquery jcarousel

我已经设置了垂直自动滚动条。

[由neuroflux编辑]问题发生在我处于“循环”模式 - 到达旋转木马的结束或开始时,它只是一遍又一遍地重复相同的幻灯片。[/ edit]

.jcarousel-skin-tango .jcarousel-container {

        }

        .jcarousel-skin-tango .jcarousel-direction-rtl {
            direction: rtl;
        }

        .jcarousel-skin-tango .jcarousel-container-horizontal {
            width: 245px;
            padding: 20px 40px;
        }

        .jcarousel-skin-tango .jcarousel-container-vertical {
            width: 75px;
            height: 245px;
            padding: 40px 20px;
        }
        .jcarousel-skin-tango .jcarousel-clip {
            overflow: hidden;
        }

        .jcarousel-skin-tango .jcarousel-clip-horizontal {
            width:  245px;
            height: 75px;
        }

        .jcarousel-skin-tango .jcarousel-clip-vertical {
            width:  75px;
            height: 245px;
        }

        .jcarousel-skin-tango .jcarousel-item {
            width: 75px;
            height: 75px;
        }

        .jcarousel-skin-tango .jcarousel-item-horizontal {
            margin-left: 0;
            margin-right: 10px;
        }

        .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-item-horizontal {
            margin-left: 10px;
            margin-right: 0;
        }

        .jcarousel-skin-tango .jcarousel-item-vertical {
            margin-bottom: 10px;
        }

        .jcarousel-skin-tango .jcarousel-item-placeholder {
            background: #fff;
            color: #000;
        }

的javascript

function mycarousel_initCallback(carousel)
            {
                // Disable autoscrolling if the user clicks the prev or next button.
                carousel.buttonNext.bind('click', function() {
                    carousel.startAuto(0);
                });

                carousel.buttonPrev.bind('click', function() {
                    carousel.startAuto(0);
                });

                // Pause autoscrolling if the user moves with the cursor over the clip.
                carousel.clip.hover(function() {
                    carousel.stopAuto();
                }, function() {
                    carousel.startAuto();
                });
            };
            jQuery('#carousel').jcarousel({
                auto: 2,
                wrap: 'circular',
                vertical: true,
                initCallback: mycarousel_initCallback
            });

有这样做的原因吗?我在li项目中添加了宽度和高度,但我不知道为什么它不起作用

1 个答案:

答案 0 :(得分:0)

试试这段代码

$('ul#carousel').jcarousel({
    auto:true,
    scroll:1,  //this number must less than the number of list item you have
    visible:2, //this number must less than the number of list item you have
    vertical: true,
    wrap: 'last',
    initCallback: mycarousel_initCallback
    });