shmuli
shmuli

Reputation: 5192

Benchmarking/testing fastclick.js

I recently integrated fastclick.js into my project to eliminate the 300ms delay when physically tapping one of the links on a touchscreen device. Now I'd like to test it to make sure that it's integrated properly. If this is properly integrated I should be able to benchmark the 300ms speed difference.

(According to Google...mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.)

I'm having difficulty thinking up the logic I can use to benchmark this, however...

The issue is that if I bind this to the link clicking event (and set var startTime = new Date(); there), it will only run the benchmarks after the link is registered (after the 300ms), and I won't be able to get an accurate benchmark that way.

Any ideas on how I can benchmark the difference and test that fastclick.js is properly integrated into my project?

I can try starting the timer at the mouseover event, but is there a better alternative to that?

Here's the link to the fastclick.js repository on GitHub

Upvotes: 1

Views: 423

Answers (1)

dkellner
dkellner

Reputation: 9926

Use the difference of "mousedown" and "click" event. On touch devices you also have "touchstart", use that instead of mousedown.

Upvotes: 1

Related Questions