A Pen by Jorik Tangelder on CodePen.
Created
July 17, 2015 09:43
-
-
Save atolmachev/9c721c45e520a0f93bcf to your computer and use it in GitHub Desktop.
Basic Hammer.js example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://hammerjs.github.io/dist/hammer.js"></script> | |
<div id="myElement"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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