Skip to content

Instantly share code, notes, and snippets.

@atolmachev
Created July 17, 2015 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atolmachev/9c721c45e520a0f93bcf to your computer and use it in GitHub Desktop.
Save atolmachev/9c721c45e520a0f93bcf to your computer and use it in GitHub Desktop.
Basic Hammer.js example
<script src="https://hammerjs.github.io/dist/hammer.js"></script>
<div id="myElement"></div>
var myElement = document.getElementById('myElement');
// create a simple instance
// by default, it only adds horizontal recognizers
var mc = new Hammer(myElement);
// listen to events...
mc.on("panleft panright tap press", function(ev) {
myElement.textContent = ev.type +" gesture detected.";
});
#myElement {
background: silver;
height: 300px;
text-align: center;
font: 30px/300px Helvetica, Arial, sans-serif;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment