简体   繁体   中英

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

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

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