Home » Javascript » Owl carousel sets “active” class to visible elements plus one only on first slide

Owl carousel sets “active” class to visible elements plus one only on first slide

Posted by: admin August 19, 2018 Leave a comment

Questions:

I have a very simple slider that changes the number of visible slides on different breakpoints.

 obj.owlCarousel
  margin: 30,

  responsive:
    0:
      items: 2,
      nav: true,
      loop: false
    500:
      items: 3,
      nav: true,
      loop: false
    800:
      items: 4,
      nav: true,
      loop: false
    900:
      items: 5,
      nav: true,
      loop: false
    1000:
      items: 6,
      nav: true,
      loop: false

  navText: [
    "<i class='icon--arrow-left-circle'></i>",
    "<i class='icon--arrow-right-circle'></i>"
  ]

I want to check the number of the visible slides by counting the items with the “active” class.

My problem is that on the first slide (e.g. with 6 visible items) I get 7 “active” items, but from the 2nd slide the “active” items number gets set correctly.

Answers: