0

我有结构

<div>
  <ul>
    <li><a></a></li>
    <li><a></a></li>
    <li><a></a></li>
  </ul>
</div>

我为 iphone/ipad 创建了滑动,我在 DIV 上设置了溢出:隐藏并上下移动 UL

问题是当我开始touchstart事件时,通过将手指放在链接<a></a>上并上下移动手指进行滑动,滑动完成后页面的位置发生了变化,链接点击工作......我需要防止那

我只想更改页面的位置,并且仅在 touchstart 之后发生 touchend 时,它们之间没有 touchmove ...

请给我建议,谢谢

4

1 回答 1

0
inner_container.bind('touchstart', function(e) {
//e.preventDefault();
   .... 
});

inner_container.on('click', 'a', function(e) {
  if(touch_moving){
    touch_moving = 0;
    return false;
  }
});

inner_container.bind('touchmove', function(e) {
  touch_moving = 1;
  ...
});

请注意,在 touchstart 中默认不会被阻止!

于 2012-08-20T12:47:23.303 回答