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
About the Authors
About the Reviewers
Related Plugin Resources

Time for action – implementing gesture support

Refer to the following steps to implement multitouch gestures in your app using the Hammer JavaScript library:

  1. Open the command-line tool and create a new PhoneGap project called hammer:

    $ cordova create hammer
  2. Using the command-line tool, add the platform you want to use for this test (Android, Blackberry, iOS, or Windows Phone 8):

    $ cordova platform add android
  3. Download the Hammer-related files from and save it in the www/js folder. You can find both hammer.min.js and hammer.js files in the download bundle from GitHub. You can just keep the hammer.min.js file and delete the rest.

  4. Include the hammer.min.js file in your index.html file to start using Hammer:

    <script src=”js/hammer.min.js”></script>
  5. Add a div element named touch to the page body. This element will be attached to all the touch events we are going to create:

    <div id=”touch”>Try Me</div>
  6. Now, let's create the event listeners...