这很简单,我敢肯定,但目前对我来说太复杂了。
Swipe.js是一种移动滑块,它提供了关于每一张幻灯片的大量良好信息,以及在幻灯片期间和幻灯片结束时可以执行的两个功能,然而,我很难编写一些简单的逻辑来检测用户是否正在滚动到下一张幻灯片,还是以前的幻灯片:
Swipe.js: https://github.com/bradbirdsall/Swipe
可用函数:
window.mySwipe = new Swipe(document.getElementById('slider'), {
callback: function(index, elem) {},
transitionEnd: function(index, elem) {}
});Swipe的简单API
Swipe API
Swipe exposes a few functions that can be useful for script control of your slider.
prev() slide to prev
next() slide to next
getPos() returns current slide index position
getNumSlides() returns the total amount of slides
slide(index, duration) slide to set index position (duration: speed of transition in milliseconds)发布于 2013-04-04 18:43:22
像这样的东西可以把你带到那里。您可能只想在生产中的回调函数中执行此操作,但我不确定您刚才转换到的幻灯片索引是哪一个,所以我为您输入了这两个函数。
var sliderIndex = 0;
window.mySwipe = new Swipe(document.getElementById('slider'), {
callback: function(index, elem) {
if (index < sliderIndex) {
//backwards
}else{
//forwards
}
sliderIndex = index;
},
transitionEnd: function(index, elem) {
if (index < sliderIndex) {
//backwards
}else{
//forwards
}
sliderIndex = index;
}
});发布于 2018-11-27 00:26:18
检查API文档中的slideNextTransitionStart、slideNextTransitionEnd、slidePrevTransitionStart、slidePrevTransitionEnd
https://stackoverflow.com/questions/15818773
复制相似问题