L
L
Localhost2017-07-21 20:37:19
PostgreSQL
Localhost, 2017-07-21 20:37:19

How to change the carousel?

Friends, do not tell me why when there is 1 object in the carousel, it is duplicated by the number specified in js. How to make sure that it is not duplicated, but the settings for the number of output are preserved.
https://codepen.io/Nelis/pen/reEjZz

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Larisa Moroz, 2017-07-21
@selo

var count_items = $('.owl-carousel .item').length;

$('.owl-carousel').owlCarousel({
…
responsive: {
    0: {
      items: 1
    },
    600: {
      items:  count_items >= 3 ? 3 : count_items
    },
    1000: {
      items: count_items >= 5 ? 5 : count_items
    }
  }
})

If you need to add elements, you will have to reinitialize $('.owl-carousel').owlCarousel each time…

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question