javascript - 使用 Glide.js 获取当前幻灯片索引
问题描述
当我使用 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();
解决方案
尝试使用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)
推荐阅读
- ios - 如何检测 SwiftUI 视图何时被拖过
- nginx - Nginx 错误日志,如果每小时超过一定数量,则跳过日志记录
- firebase - Firestore - 添加其他文档而不创建副本
- reactjs - 如何在博览会上反应原生导航时隐藏标题导航栏?
- github - 有没有办法将 Github README 视频链接包装在表格单元格中?
- jenkins - 詹金斯中的未知阶段部分“withKubeConfig”
- amazon-web-services - 从除当前设备之外的所有设备注销 AWS 放大
- bash - 我在 tsv 文件中的每个单元格有多个值,如何拆分它们并与另一列中的相应值匹配?
- python - polyglot - TypeError:'function'对象不可下标
- php - 在浏览器中工作,无法使用 PHP