Reputation: 1227
I am trying to run an alert when a swipe-up gesture occurs anywhere on the document; and, ultimately also when a 2 finger swipe-gesture occurs.
I've used hammer.js to listen for gestures before and this code seems valid to me, but for some reason the alerts are not happening.
Any ideas why ?
Here is the code:
<!Doctype HTML>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Two Swipe!</title>
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="http://raw.github.com/EightMedia/hammer.js/master/dist/jquery.hammer.min.js"></script>
<script type="text/javascript">
var hammer = $(document).hammer();
hammer.on('swipeup', function(event) {
alert("swiped-up!");
if( event.gesture.touches.length == 2 )
alert("two swiped!");
});
</script>
</body>
</html>
Upvotes: 1
Views: 1588
Reputation: 668
Checked the source. If you look at the swipe gesture here at line 208, you'll see that it has max touches set to 1. My guess is that this is limiting you from seeing multiple touches. You could probably either modify this code to suit your needs or write a custom listener for multitouch swipes.
Upvotes: 1