Owl-Carousel, scroll two items at a time

ぃ、小莉子 提交于 2019-12-07 10:27:44

问题


I am working on a slider with Owl-Carousel 2 (beta), but there is a lot that doesn't work well. I want the owlCarousel to work like this:

It should scroll 2 items at a time, showing 2 items at a time. So: [0,1] slide [2,3] slide [4,5]

On mobile, it should show one picture and scroll by 1 picture at a time.

owl = $('.owl-carousel')
  owl.owlCarousel({
    center: true,
    loop: false,
    margin: 20,
    items: 2,
    responsive: {
      0: {
        items: 1,
        navigation: true,
        nav: true
      },
      640: {
        items: 2,
        navigation: true,
        nav: true
      }
    },
    scrollPerPage: true,
    navigation: true
  }).css("z-index", 0)

回答1:


You can use the slideBy option.

owl = $('.owl-carousel')
  owl.owlCarousel({
    center: true,
    loop: false,
    margin: 20,
    items: 2,
    responsive: {
      0: {
        items: 1,
        navigation: true,
        nav: true,
        slideBy: 1 // <!-- HERE
      },
      640: {
        items: 2,
        navigation: true,
        nav: true,
        slideBy: 2 // <!-- HERE
      }
    },
    scrollPerPage: true,
    navigation: true
  }).css("z-index", 0)


来源:https://stackoverflow.com/questions/32843347/owl-carousel-scroll-two-items-at-a-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!