简体   繁体   English

HostListener的Angular 2触摸延迟

[英]Angular 2 touch delay with HostListener

In my project I'm looking to remove the common 300ms touch delay issue. 在我的项目中,我希望消除常见的300ms触摸延迟问题。 My application may be used on devices that support both clicking and touching, so I need to support both. 我的应用程序可能在同时支持点击和触摸的设备上使用,因此我需要同时支持两者。

The common solution seems to be to bind both click and touch events to clickable elements, and then stop propagation to prevent it from double triggering. 常见的解决方案似乎是将单击和触摸事件都绑定到可单击的元素,然后停止传播以防止它被双重触发。 I've been trying to implement a solution similar to this through a custom directive. 我一直在尝试通过自定义指令实现类似于此的解决方案。 It seems however that HostListeners only allow one event at a time. 但是,似乎HostListeners一次仅允许一个事件。

I'd like to avoid using some sort of setTimeout trick. 我想避免使用某种setTimeout技巧。 Is there any concrete way to accomplish this? 有什么具体方法可以做到这一点?

You could take a look at https://github.com/hammerjs/hammer-time . 您可以看看https://github.com/hammerjs/hammer-time Very small library, doing exactly what you want. 很小的库,完全可以满足您的需求。

It uses a way to polyfill the w3c spec of the touch action css property 它使用一种方法来填充触摸动作css属性的w3c规范

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM