prevent touchstart when swiping

前端 未结 11 2074
萌比男神i
萌比男神i 2020-11-30 20:09

I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping.

The catch is combining th

11条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 21:05

    var touchmoved;
    $('button').on('touchend', function(e){
        if(touchmoved != true){
            // button click action
        }
    }).on('touchmove', function(e){
        touchmoved = true;
    }).on('touchstart', function(){
        touchmoved = false;
    });
    

提交回复
热议问题