1

I have an owl carousel slider with items, the functionality is

if there are more than 5 items in the carousel,

to make loop = true

autoplay = true

else make loop = false.

autoplay = false

$(document).ready(function() {
  $('#our_people_slider').owlCarousel({
  loop:islooped,

  nav:false,

  autoplay:isautoplay,

  stagePadding: 170,

  margin:42,

  items:1,

  lazyLoad: true,

  autoWidth:true,

  autoHeight:false,

  singleItem: true,

  center:iscenter,

  itemsScaleUp:true,


  autoplayTimeout: 2000,


  autoplaySpeed:2000,


  responsive:{

    1024:{
      items:5,
    }
  },
})

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

  console.log(totalItems)
  if (totalItems >= 4) {

   var islooped = true;

   var isautoplay = true;

   var iscenter = true;


    $('#our_people_slider').removeClass('slider-diable');

    alert("true");
  } 
  else {

     var islooped = false;

     var isautoplay = false;

     var iscenter = false;

    $('#our_people_slider').addClass('slider-diable');

    alert("false");
  }
});
BenM
  • 52,573
  • 26
  • 113
  • 168
  • 1
    You need to switch around your logic, you're instantiating the Owl Carousel before running your checks. Are you able to share your markup? – BenM Jul 16 '19 at 11:42
  • I'm trying to write a condition to say if there's more than one 5 items in the carousel, to make loop = true else make loop = false. it doesn't seem to be working. – DEBANSHU MALLICK Jul 17 '19 at 10:11

0 Answers0