【问题标题】:Get Current slide index with Glide.js使用 Glide.js 获取当前幻灯片索引
【发布时间】:2020-06-03 07:21:49
【问题描述】:

当我使用 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】:

    尝试使用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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多