angular-gestures
angular-gestures copied to clipboard
HUGE BUG - ABSOLUTELY NO STOPPROPAGATION() and NO PREVENTDEFAULT()
How can a plugin based on events have no concept of stop propagation and prevent default especially when it piggy backs off of the Hammer.js that supports this???
I have to say that since I spent the time to integrate this into my solution I will be quite annoyed if there is not a fix or a hot fix or something to hold this BIG BUG.
The following sitch is a NO GO - index.html --
someController.js -- angular.module('controllers').controller("SomeController", ["$scope", "$http", "SomeService", function($scope, $http, SomeService) { $scope.tapEvent = function(id) { alert('this click should not show for ' + id); }; $scope.nestedTapEvent = function(id, event) { event.stopPropagation(); event.preventDefault(); event.gesture.stopPropagation(); event.gesture.preventDefault(); event.gesture.stopDetect(); alert('this should def show for ' + id + ' but it should not fire tapEvent'); };
Any PR is welcome :)
I'll try to work on integrating hammer 2.0 shortly..
I did not get stopPropagation() to work properly yet but I will try to get it done soon
@wzr1337 what's the status of this? is there a fix already? I'm having similar problems with propagation.
actually I am to busy currently to work on it and Ido not yet have a fix for it..
I just worked on this for a while and couldn't figure it out. Do you think it's because the event is being passed inside a $timeout?
+1 on this. Kind of makes this otherwise awesome module unusable.
The thing is that hammer does not provide these features on its regular events. Only if you let hammer fire actual DOM events, stopPropagation and default prevention become usable with some drawbacks like performance..
I am currently fiddling around with some additional code, but I need some more experiments as it is not all to obvious how to achieve the goal :(
On Friday, January 30, 2015, Johan Gyllenspetz [email protected] wrote:
+1 on this. Kind of makes this otherwise awesome module unusable.
— Reply to this email directly or view it on GitHub https://github.com/wzr1337/angular-gestures/issues/23#issuecomment-72166159 .
- Dr. Patrick Bartsch (web)
Hammer provides an event objects for their event handlers. As I see it in their documentation, the event object has a srcEvent object which represents the source of the event. The angular-gestures plugin directives passes the $event object that has this srcEvent object.
To stop propagation you can simply do $event.srcEvent.stopPropagation(), they also have provided a direct access for the srcEvent for preventDefault(), so you can do $event.preventDefault() as you like or do $event.srcEvent.preventDefault().
Source: Hammer API