结束时停止滑动


Stop slide when ended

我正在使用idangero滑块,当到达第二个滑块时,我想停止滑块。(滑块:http://www.idangero.us/sliders/swiper/api.php)

用户应该只能滑动一次,之后用户就不能滑动了。你可以在这里看到一个例子:www.bvweijen.nl/23g/slider/index.php

它是一个移动滑块。

我试过这个:

  <script>
            var mySwiper = new Swiper('.swiper-container',{
               speed : 800,
               grabCursor: true,
               paginationClickable: true,
               onSlideChangeEnd : function() {
               if(mySwiper.activeIndex > 0){
                    mySwiper.params.noSwiping = true
                }
                //alert('OMG you touch the slide!') 
           },
        })
    </script>

他可以找到activeIndex,但noSwiping=true不起作用。

我希望有人能帮助我。

您没有正确阅读API文档。在你的辩护中,不清楚"防止元素滑动"会做什么。无论如何,以下是状态:

noSwiping: If true, then you can add "noSwipingClass" class to swiper's slide to prevent/disable swiping on this element.

这意味着您必须设置一个类,即noSwipingClass,并且必须预先设置noSwiping = true。试试这样的东西:

<script>
        var mySwiper = new Swiper('.swiper-container',{
           noSwiping: true,
           noSwipingClass: 'do_not_swipe',
           speed : 800,
           grabCursor: true,
           paginationClickable: true,
           onSlideChangeEnd : function() {
           if(mySwiper.activeIndex > 0){
                $('.swiper-container').addClass('do_not_swipe);
            }
            //alert('OMG you touch the slide!') 
       },
    })
</script>