【问题标题】:Swiper API - How to get alert on swipe for left side?Swiper API - 如何在左侧滑动时获得警报?
【发布时间】:2015-09-22 14:22:30
【问题描述】:

我在我的应用程序上使用 Swiper API。我想知道,我如何让用户一边浏览。我已阅读 (http://www.idangero.us/swiper/api/#.VgFind9VhBc) 上的文档,但没有找到答案。

【问题讨论】:

    标签: jquery html browser swiper


    【解决方案1】:

    这是另一个例子:

    swiper.on( 'slideChange', function() {
       if ( swiper.activeIndex > swiper.previousIndex ) {
           alert( 'left' );
       } else {
           alert( 'right' );
       }
    });
    

    Swiper 对象内部有索引和其他信息。您不需要事件。

    尝试查看对象:

    console.log(swiper);
    

    【讨论】:

      【解决方案2】:

      你可以这样做:

      galleryExample.on('slideChangeStart',function(event){
                     if(event.activeIndex > event.previousIndex){
                         alert('left');
                     }else{
                         alert('right');
                     }
                  });
      

      event.activeIndex 是滑块的活动项目,event.previousIndex 是滑块之前所在项目的索引。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-11-21
        • 2012-08-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2017-09-28
        • 1970-01-01
        相关资源
        最近更新 更多