我正在用Swiper编码滑块,但是在向左/向右滑动时检查方向转换时遇到问题。我需要检查进度功能中的方向,在代码中的正确位置进行注释。
var headerSlider = new Swiper('.swiper-header', {
grabCursor: true,
watchSlidesProgress: true,
slidesPerView: 1,
on: {
progress: function() {
for (var i = 0; i < this.slides.length; i++) {
var slideProgress = this.slides[i].progress;
var innerOffset = this.width * 0.5;
var innerTranslate = slideProgress * innerOffset;
//
//I need here to check direction transition.
//Like slide to prev or next slide
//
this.slides[i].querySelector(".slide-image").style.transform = "translate3d(" + innerTranslate + "px, 0, 0)";
}
},
touchStart: function() {
for (var i = 0; i < this.slides.length; i++) {
this.slides[i].style.transition = "";
}
);
},
setTransition: function(speed) {
for (var i = 0; i < this.slides.length; i++) {
this.slides[i].style.transition = speed + "ms";
this.slides[i].querySelector(".slide-image").style.transition =
speed + "ms";
}
}
}});