简体   繁体   English

基准测试/测试fastclick.js

[英]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. 我最近将fastclick.js集成到我的项目中,以消除在物理上触摸触摸屏设备上的链接之一时的300ms延迟。 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. 如果正确集成,我应该能够对300ms的速度差异进行基准测试。

(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.) (根据Google ...,从您点击按钮触发点击事件开始,移动浏览器将等待大约300毫秒。其原因是浏览器正在等待查看您是否实际上在执行双击。)

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. 问题是,如果我将其绑定到链接单击事件(并在其中设置var startTime = new Date(); ),它将仅在链接注册后(300毫秒后)运行基准测试,而我不会能够以这种方式获得准确的基准。

Any ideas on how I can benchmark the difference and test that fastclick.js is properly integrated into my project? 关于如何基准化差异并测试fastclick.js是否正确集成到我的项目中的任何想法?

I can try starting the timer at the mouseover event, but is there a better alternative to that? 我可以尝试在mouseover事件上启动计时器,但是还有更好的选择吗?

Here's the link to the fastclick.js repository on GitHub 这是GitHub上fastclick.js存储库的链接

Use the difference of "mousedown" and "click" event. 使用“ mousedown”和“ click”事件的区别。 On touch devices you also have "touchstart", use that instead of mousedown. 在触摸设备上,您也具有“ touchstart”,请使用它代替鼠标按下。

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

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