Skip to content

Instantly share code, notes, and snippets.

@jmaicher
Last active August 29, 2015 13:57
Show Gist options
  • Save jmaicher/9779769 to your computer and use it in GitHub Desktop.
Save jmaicher/9779769 to your computer and use it in GitHub Desktop.
Example: Nested hammer.js instances
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<style>
#foo, #bar { background-color: rgba(1,1,1,.5); }
#foo { height: 100px; padding: 100px; }
#bar { height: 100px; }
</style>
</head>
<body>
<div id="foo">
<div id="bar"></div>
</div>
<script src="hammer.js"></script>
<script>
var foo = document.getElementById('foo'),
bar = document.getElementById('bar');
Hammer(foo, {}).on('dragstart drag dragend', function(evt) {
console.log('foo#' + evt.type);
});
Hammer(bar, {}).on('dragstart drag dragend', function(evt) {
console.log('bar#' + evt.type);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment