使用 jQuery 在移动设备上处理长按和双击事件的最佳方法是什么? [英] What's the best way to handle longtap and double-tap events on mobile devices using jQuery?

查看:30
本文介绍了使用 jQuery 在移动设备上处理长按和双击事件的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找添加doubletap"和longtap"事件的最佳解决方案,以便与 jQuery 的 live()、bind() 和 trigger() 一起使用.我推出了自己的快速解决方案,但它有一些问题.有没有人有他们推荐的插件,或者他们想要分享的他们自己的实现?

I'm looking for the best solution to adding both "doubletap" and "longtap" events for use with jQuery's live(), bind() and trigger(). I rolled my own quick solution, but it's a little buggy. Does anyone have plugins they would recommend, or implentations of their own they'd like to share?

推荐答案

它已报告给 jQuery 作为一个错误,但由于双击与双击不同,它没有高优先级.但是,策划者 Raul Sanchez 为 doubletap 编写了一个 jquery 解决方案,您可能可以使用它!这是链接,正在处理移动 Safari.

It has been reported to jQuery as a bug, but as doubletapping isn't the same as doubleclicking, it does not have a high priority. However, mastermind Raul Sanchez coded a jquery solution for doubletap which you can probably use! Here's the link, works on mobile Safari.

易于使用:

$('selector').doubletap(function() {});

-编辑-

还有一个 longtap 插件这里!您可以在 iPad 或 iPhone 上查看演示此处.

And there's a longtap plugin here! You can see a demo on your iPad or iPhone here.

这篇关于使用 jQuery 在移动设备上处理长按和双击事件的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆