最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Autoplay more than one item? - Stack Overflow

programmeradmin6浏览0评论

If the carousel shown 4 items, to set the autoplay replaced with 4 new items. Here the demo if you click on the item pagination, you can see the effect. But if we set auto play, then change only one item?

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

php / html code (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>

If the carousel shown 4 items, to set the autoplay replaced with 4 new items. Here the demo if you click on the item pagination, you can see the effect. But if we set auto play, then change only one item?

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

php / html code (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>
Share Improve this question edited May 12, 2015 at 17:00 isherwood 61.2k16 gold badges121 silver badges170 bronze badges asked May 12, 2015 at 15:53 SalinesSalines 5,7673 gold badges27 silver badges54 bronze badges 0
Add a ment  | 

2 Answers 2

Reset to default 5

I'd set slideBy to your item count:

$(".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
        }
    }
});

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

In Owl Carousel 2 you use the option: slideBy:'page' for sliding the entire "page" on autoPlay (or navigation buttons).

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

发布评论

评论列表(0)

  1. 暂无评论