zoukankan      html  css  js  c++  java
  • jq判断触屏左右滑动方向

    $('body').on('touchstart', '.slide-box>ul>li', function(e) {
    var touch = e.originalEvent,
    startX = touch.changedTouches[0].pageX;

    $(this).on('touchmove', function(e) {
    e.preventDefault();
    touch = e.originalEvent.touches[0] ||
    e.originalEvent.changedTouches[0];
    if (touch.pageX - startX > 20) {//向左
    $('#preBtn').click();
    $(this).off('touchmove');

    } else if (touch.pageX - startX < -20) {//向右

    $('#nextBtn').click();
                $(this).off('touchmove');

    };

    });

    // Return false to prevent image
    // highlighting on Android
    //return false;

    }).on('touchend', function() {
    $(this).off('touchmove');
    });
  • 相关阅读:
    Facade
    Adapter
    Bridge
    Factory
    Singleton
    Decorator
    Template Method
    设计模式
    寻找最小的k个数
    java并发编程(4)--线程池的使用
  • 原文地址:https://www.cnblogs.com/niwalala/p/6912912.html
Copyright © 2011-2022 走看看