简体   繁体   中英

Angular 2 touch delay with HostListener

In my project I'm looking to remove the common 300ms touch delay issue. 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.

I'd like to avoid using some sort of setTimeout trick. Is there any concrete way to accomplish this?

You could take a look at 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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