RyanMullins / angular-hammer

Hammer.js v2 support for AngularJS
http://ryanmullins.github.io/angular-hammer/
MIT License
188 stars 55 forks source link

preventGhosts not working #22

Closed skawaguchi closed 9 years ago

skawaguchi commented 9 years ago

A simple setup like this is triggering the tap event multiple times. Tested in Chrome, Safari, Firefox, Mobile Safari.

Template:

<a hm-tap="myFunction( $event, someItem )">My Link</a>

Controller:

$scope.myFunction = function ( ev, item ) {
  ev.preventDefault();
  console.log ( 'hello' ); 
};

This fires console.log twice.

I tried adding Hammer Manager Options didn't help, but the event still fires twice:

<a hm-tap="myFunction( $event, someItem )" hm-manager-options='{"enabled":true,"preventGhosts":true}'>My Link</a>

The repeated call issue seems to have existed since 2.1.2. I tried both 2.1.3 and 2.1.4 with event.preventDefault() back when the event was being passed, as well as preventGhosts, and the problem still exists. Note that when I was getting the event, the type was 'tap for both calls, so it wasn't a 'tap' and then a 'click'.

It this related to the way I'm calling the $scope function? I can't see how else I can easily pass a $scope object to myFunction.

skawaguchi commented 9 years ago

I created a pen for this. However, it's not showing the error so it must be my code.

RyanMullins commented 9 years ago

I commented on your other issue. I think it should be working now in v2.1.5, at least it is with some code here at my office. Try it again and update me as necessary.