angular-gestures icon indicating copy to clipboard operation
angular-gestures copied to clipboard

HUGE BUG - ABSOLUTELY NO STOPPROPAGATION() and NO PREVENTDEFAULT()

Open jonnydungeons opened this issue 11 years ago • 9 comments

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.

jonnydungeons avatar Oct 27 '14 00:10 jonnydungeons

The following sitch is a NO GO - index.html --

View Details

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'); };

jonnydungeons avatar Oct 27 '14 00:10 jonnydungeons

Any PR is welcome :)

I'll try to work on integrating hammer 2.0 shortly..

wzr1337 avatar Oct 29 '14 11:10 wzr1337

I did not get stopPropagation() to work properly yet but I will try to get it done soon

wzr1337 avatar Nov 10 '14 21:11 wzr1337

@wzr1337 what's the status of this? is there a fix already? I'm having similar problems with propagation.

gercheq avatar Dec 02 '14 01:12 gercheq

actually I am to busy currently to work on it and Ido not yet have a fix for it..

wzr1337 avatar Dec 07 '14 08:12 wzr1337

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?

mullen3 avatar Dec 17 '14 18:12 mullen3

+1 on this. Kind of makes this otherwise awesome module unusable.

gyllen avatar Jan 30 '15 07:01 gyllen

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)

wzr1337 avatar Jan 30 '15 12:01 wzr1337

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

ryeballar avatar Nov 20 '15 10:11 ryeballar