Time for action – implementing gesture support
Refer to the following steps to implement multitouch gestures in your app using the Hammer JavaScript library:
Open the command-line tool and create a new PhoneGap project called
hammer
:$ cordova create hammer
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
Download the Hammer-related files from https://github.com/hammerjs/hammer.js and save it in the
www/js
folder. You can find bothhammer.min.js
andhammer.js
files in the download bundle from GitHub. You can just keep thehammer.min.js
file and delete the rest.Include the
hammer.min.js
file in yourindex.html
file to start using Hammer:<script src=”js/hammer.min.js”></script>
Add a
div
element namedtouch
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>
Now, let's create the event listeners...