1

我目前正在使用以下调用使用 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>

但是,我的客户不喜欢这种工作方式,并希望它以相同的方向滑回起点,或者滑回以显示其他图像。

知道这是否可能吗?

4

1 回答 1

2

要返回第一张图像,您可以使用以下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);
        }
     }          
   });
});
于 2013-07-21T15:05:10.630 回答