代码复制源库
以注释的方式阅读hammer.js源码
Visit hammerjs.github.io for detailed documentation.
// get a reference to an element
var stage = document.getElementById('stage');
// create a manager for that element
var mc = new Hammer.Manager(stage);
// create a recognizer
var Rotate = new Hammer.Rotate();
// add the recognizer
mc.add(Rotate);
// subscribe to events
mc.on('rotate', function(e) {
// do something cool
var rotation = Math.round(e.rotation);
stage.style.transform = 'rotate('+rotation+'deg)';
});
An advanced demo is available here: http://codepen.io/runspired/full/ZQBGWd/
Read the contributing guidelines.
For PRs.
- Use Angular Style commit messages
- Rebase your PR branch when necessary
- If you add a feature or fix a bug, please add or fix any necessary tests.
- If a new feature, open a docs PR to go with.
You can get the pre-build versions from the Hammer.js website, or do this by yourself running
npm install -g grunt-cli && npm install && grunt build