angular 的 ngTouch 库可以用于检测长按(触摸/保持/释放到位)事件吗? [英] Can angular's ngTouch library be used to detect a long click (touch/hold/release in place) event?

查看:22
本文介绍了angular 的 ngTouch 库可以用于检测长按(触摸/保持/释放到位)事件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 AngularJS 应用程序需要能够检测触摸事件的开始和停止(无需滑动).例如,我需要在触摸开始时执行一些逻辑(用户按下手指并按住),然后在同一触摸结束时执行不同的逻辑(用户移开手指).我正在考虑为此任务实现 ngTouch,但 ngTouch.ngClick 指令的文档仅提到在点击时触发事件.ngTouch.$swipe 服务可以检测触摸事件的开始和停止,但前提是用户在触摸时实际滑动(水平或垂直移动手指).谁有想法?我是否只需要编写自己的指令?

My AngularJS app needs to be able to detect both the start and stop of a touch event (without swiping). For example, I need to execute some logic when the touch begins (user presses down their finger and holds), and then execute different logic when the same touch ends (user removes their finger). I am looking at implementing ngTouch for this task, but the documentation for the ngTouch.ngClick directive only mentions firing the event on tap. The ngTouch.$swipe service can detect start and stop of the touch event, but only if the user actually swiped (moved their finger horizontally or vertically) while touching. Anyone have any ideas? Will I need to just write my own directive?

推荐答案

11/25/14 更新:

Update 11/25/14:

等宽 angular-hammer 库现在已经过时,因此 Hammer.js 团队建议使用 ryan mullins 版本,基于hammer v2.0+ 构建.

The monospaced angular-hammer library is outdated right now, so the Hammer.js team recommend to use the ryan mullins version, which is built over hammer v2.0+.

我深入研究了 ngTouch,据我所知,除了点击和滑动之外,它不支持任何其他东西(截至撰写本文时,版本 1.2.0).我选择使用更成熟的多点触控库 (hammer.js) 和经过良好测试和维护的 angular 模块 (angular-hammer),它将hammer.js 的所有多点触控功能作为属性指令公开.

I dug into ngTouch and from what I can tell it has no support for anything other than tap and swipe (as of the time of this writing, version 1.2.0). I opted to go with a more mature multi-touch library (hammer.js) and a well tested and maintained angular module (angular-hammer) which exposes all of hammer.js's multi-touch features as attribute directives.

https://github.com/monospaced/angular-hammer

这篇关于angular 的 ngTouch 库可以用于检测长按(触摸/保持/释放到位)事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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