javascript - 滑动 2.0 : Changing the continuous nature of the slider

标签 javascript swipe

我目前正在使用 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/

相关文章:

javascript - jQuery 移动响应面板滑动打开/关闭关闭

Android Cursor RecyclerView 在滑动时轻弹

javascript - 检查 Javascript isset 中是否设置了 2 个 php 变量

javascript - 如何在 Javascript + Node 中传递参数?

javascript - jquery.min.js 加载资源失败

javascript - 如何在vuejs中访问对象内部的方法?

javascript - 如何避免 Chrome 在解析此 JSON 时崩溃?

ios - 静态 UITableView 中的可滑动单元格

jquery - 如何检测 jQuery Mobile 中的滑动位置

android - SwipeRefreshLayout 内的 RecyclerView,左/右滑动可更改 View