rdmueller
rdmueller

Reputation: 11012

onClick event in android webview too slow

I've got the feeling that javascript itself is pretty fast in an andorid webview, but there is a long delay between touching an element and the onclick event beeing fired.

I could imagine that this is a feature if you navigate between pages - you first see the highlight on the element, and then you see the effect (navigation). But for applications, this is too slow.

Is there a way to change this behavior?

Or is there maybe another event I should go for, like an onHover or onTouch? Something which fires way before the onClick?

Upvotes: 3

Views: 4513

Answers (2)

Marcelo Amorim
Marcelo Amorim

Reputation: 1682

This is a known 'issue' related to 300ms due to user tapping/zooming at display:

http://updates.html5rocks.com/2013/12/300ms-tap-delay-gone-away

In the near future, this seems to be solved, in static sized layouts, adding information at header. But the actual webkit webview version does not have/consider this option.

In my case, the solution was use Tappy lib:

https://github.com/filamentgroup/tappy

Just import it, and bind to each element that has an click event, and you will see the difference.

Just one more point: I adjusted the timer to 100000ms (default:1000ms) to avoid event repetition in some specific cases.

Upvotes: 3

rdmueller
rdmueller

Reputation: 11012

I guess I've found the answer...

If you take a look at jQuery mobile, you'll find a tap event. This works instantly - exactly as I need it.

Looking deeper into the source, I've found that the tap event uses a mousedown ....

Upvotes: 0

Related Questions