用Glide.js获取当前幻灯片索引号

问题描述 投票:0回答:1

当我使用GLide.js在元素之间滑动时,如何获得当前的幻灯片索引号?

 const config = {
    type: "carousel",
    perView: 5,
    startAt: 2,
    perTouch: 1,
    focusAt: "center",
  };
  new Glide(".glide", config)
    .on("swipe.end", function (event) {
      console.log(event);
    })
    .mount();
javascript jquery carousel swiper glidejs
1个回答
2
投票

试试使用 glide.index

const config = {
  type: "carousel",
  perView: 5,
  startAt: 2,
  perTouch: 1,
  focusAt: "center",
};

var glide = new Glide(".glide", config)

glide.on("swipe.end", function(event) {
  console.log('on swipe.end', glide.index)
})

glide.mount()

console.log(glide.index)
© www.soinside.com 2019 - 2024. All rights reserved.