【问题标题】:canceling touchend event when touchmove startstouchmove 开始时取消 touchend 事件
【发布时间】:2012-03-27 18:40:09
【问题描述】:

我的网络应用程序中有一个可滚动列表,使用 scrollability 来处理 overflow:scroll 功能。虽然当我完成滚动并将手指移出屏幕时,下面的事件也会触发。

$('li').live('touchend', function (e) {
    //...
});

问题是我只希望上面的这个事件在动作之前没有 touchmove 事件时触发。

可以从touchmove 事件内部抑制touchend 事件吗? 所以它更好地模拟了 iOS UITableView 组件?当touchmove 启动时,它会取消touchend 的目标

【问题讨论】:

  • 也许在touchmove 中设置一个标志,可以在touchend 中进行测试,如果设置了标志,则跳过该功能,可能还有preventDefault()(无论哪种方式,最后重置标志)。
  • 非常感谢 Yaniro,在这种情况下,这是最明智的做法。如果您可以将其设置为分析器,我很乐意将其标记为正确:)

标签: javascript ios mobile touch web-applications


【解决方案1】:

touchmove 中设置一个标志,可以在touchend 中进行测试,如果设置了标志,则跳过该功能,可能还有preventDefault()(无论哪种方式,最后都重置标志)。

【讨论】:

    猜你喜欢
    • 2013-04-18
    • 1970-01-01
    • 2014-05-16
    • 2012-06-05
    • 2012-02-29
    • 2012-05-17
    • 2017-04-25
    • 1970-01-01
    • 2011-11-03
    相关资源
    最近更新 更多