Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Related Plugin Resources
Index

Handling click delays


We have seen that a mobile application can support various touch gestures. With the introduction of new technologies, differences between web apps and native mobile apps are getting close to zero, but not actually zero. One such difference is how click events are handled in mobile apps.

When you click on a button, mobile browsers wait for 300 ms to actually trigger the click event for the button that you have clicked. The actual reason is that the mobile browser waits to see whether the user wants to perform a click or a double click. After the 300 ms delay, if there is no other tap, it's considered as a single click. However, if there are no event handlers for double clicks, the delay will be unnecessary. By overcoming these delays, you can make your app more responsible and less laggy.

We are going to see an approach to avoid this 300 ms delay using the library called FastClick that is available at https://github.com/ftlabs/fastclick. The steps are as follows:

  1. Include...