我目前正在使用 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);
}
}
});
});
关于javascript - 滑动 2.0 : Changing the continuous nature of the slider,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16968205/