我目前正在使用swipe 2.0 js使用以下调用,它将最后一张图像连续返回到第一张图像。
<script>
window.mySwipe = new Swipe(document.getElementById('mySwipe'), {
startSlide: 0,
speed: 400,
auto: 3000,
continuous: true,
disableScroll: false,
stopPropagation: false,
callback: function(index, elem) {},
transitionEnd: function(index, elem) {}
});
</script>
然而,我的客户不喜欢这种工作方式,并希望它在同一方向上滑回开始,或者滑回显示其他图像。
有人知道这是可能的吗?
要返回到第一张图像,您可以使用slide()
方法:
$(document).ready(function() {
window.mySwipe = new Swipe(document.getElementById('mySwipe'), {
speed: 400,
auto: 3000,
continuous: false,
transitionEnd: function(index, elem) {
// when a transition ends we check if we have reached the last image
if(index == window.mySwipe.getNumSlides()-1) {
// if its the last image we rewind to the first one
window.mySwipe.slide(0, 1000);
}
}
});
});