11.05

移动端避免滑动屏幕触发点击事件

$(selector).on('touchstart touchmove touchend', (e) => {
  let flag = false;
  switch(e.type) {
    case 'touchSatrt': 
      flag = false;
      break;
    case 'touchmove' :
      flag = true;
      break;
    case 'touchend' :
      if(flag) {
        console.log('swiper');
        // do something
      }else {
        console.log('click');
        // do something
      }
  }
}) 

你可能感兴趣的:(11.05)