我的目标是制作一个看起来像这样的轮播:
如果您不知道自己在看什么,则有 5 个图像/项目,但只有中心的一个以全尺寸显示。靠近中心的图像更小,外部的图像更小。
我在 Owl Carousel 的第一个版本中实现了这一点,但它不支持循环,这使得这种设计很荒谬(无法到达侧面图像......)。
我是这样做的:
var owl = $("#owl-demo");
owl.owlCarousel({
pagination: false,
lazyLoad: true,
itemsCustom: [
[0, 3],
[900, 5],
[1400, 7],
],
afterAction: function(el){
.$owlItems
.removeClass('active') //what I call the center class
.removeClass('passive') //what I call the next-to-center class
this
.$owlItems
.eq(this.currentItem + 2) //+ 2 is the center with 5 items
.addClass('active')
this
.$owlItems
.eq(this.currentItem + 1)
.addClass('passive')
this
.$owlItems
.eq(this.currentItem + 3)
.addClass('passive')
}
只是向您展示了 5 个项目的代码,但我使用了一些 if 子句使其也适用于 3 和 7。该类active
仅由width: 100%
和passive
组成width: 80%
。
有谁知道如何在 Owl Carousel 2 中获得相同的结果?我正在使用_items
而不是,$owlItems
但我不知道这是否正确。没有afterAction
,并且事件/回调似乎没有像 v2 中那样工作。