这很简单,我敢肯定,但目前对我来说太复杂了。
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)