如何在元素Owl Carousel 2拖动上切换类?

时间:2019-01-02 16:56:00

标签: javascript jquery html owl-carousel

//Once I drag the element I need it to do the same thing when the links are clicked.
    $('#resources').owlCarousel({
      items: 1,
      loop: false,
      center: true,
      margin: 0,
      URLhashListener: true,
      autoplayHoverPause: true,
      startPosition: 'URLHash',
      dots: false,
      0: {
          items: 1
      },
      600: {
          items: 1
      },
      1000: {
          items: 1
      }
    });

    //add active class on click
    $('#resource-hashes .container a').click(function() {
      $(this).toggleClass('active').siblings().removeClass('active');
    });

    //I need this to do the same thing as the above code when it is dragged
    $('#resource-hashes .container a').on('changed.owl.carousel', function(event) {
      $(this).toggleClass('active').siblings().removeClass('active');
    });

0 个答案:

没有答案