自动播放多个项目?

时间:2015-05-12 15:53:07

标签: javascript jquery owl-carousel owl-carousel-2

如果旋转木马显示4项,则设置自动播放替换为4个新项目。这里是demo如果你点击项目分页,你可以看到效果。但是如果我们设置自动播放,那么只更改一个项目吗?

$(".owlcarousel").owlCarousel({
    autoplay: true,
    margin: 10,
    nav: true,
    loop: true,
    responsive: {
        0: {
            items: 1
        },
        600: {
            items: 3
        },
        1000: {
            items: 5
        }
    }
});

php / html代码(cakephp)

    <?php $brands = $this -> requestAction('/brands'); ?>
<div class="featured-brands">
    <div class="container">
        <div class="col-xs-12">
            <div class="owlcarousel">
            <?php foreach ($brands as $brand) {?>
                <div class="item"><?php echo $this->Html->image('brands/'.$brand['Brand']['id'].'/'.$brand['Brand']['image'],array('class'=>'img-responsive')); ?></div>
            <?php } ?>
            </div>
        </div>
    </div>
</div>

2 个答案:

答案 0 :(得分:3)

我将slideBy设置为您的项目数:

$(".owlcarousel").owlCarousel({
    autoplay: true,
    margin: 10,
    nav: true,
    loop: true,
    responsive: {
        0: {
            items: 1,
            slideBy: 1
        },
        600: {
            items: 3,
            slideBy: 3
        },
        1000: {
            items: 5,
            slideBy: 5
        }
    }
});

http://owlcarousel.owlgraphic.com/docs/api-options.html#slideby

答案 1 :(得分:2)

在Owl Carousel 2中,您可以使用以下选项:slideBy:'page'在autoPlay(或导航按钮)上滑动整个“页面”。

https://owlcarousel2.github.io/OwlCarousel2/docs/api-options.html