【问题标题】:Prevent click on Ipad/Iphone when sliding a jquery slider滑动 jquery 滑块时防止点击 Ipad/Iphone
【发布时间】:2012-08-20 10:46:27
【问题描述】:

我有结构

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

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

问题是当我开始touchstart事件时,通过将手指放在链接&lt;a&gt;&lt;/a&gt;上并上下移动手指进行滑动,滑动完成后页面的位置发生了变化,链接点击起作用了。 ..我需要防止这种情况发生

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

请多多指教,谢谢

【问题讨论】:

标签: jquery ipad slider touchstart touchmove


【解决方案1】:
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 中默认不会被阻止!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-02-26
    • 1970-01-01
    • 2017-02-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-05-24
    • 1970-01-01
    相关资源
    最近更新 更多