jviotti
jviotti

Reputation: 18909

Swipe in element triggers swipe in outer element

I have a HTML structure that looks something like this:

<div ng-swipe-right="outerSwipe()">

  ...

  <div ng-swipe-right="innerSwipe()">

    ...

  </div>

</div>

When I do a swipe in the inner div, outerSwipe() is also called.

Are there any workarounds?

Upvotes: 0

Views: 435

Answers (1)

Alex Choroshin
Alex Choroshin

Reputation: 6187

as tymeJV suggested, you can add to your event handler event.stopPropagation() method that prevents the event from bubbling up the DOM tree.

Example:

app.directive('ngSwipeRight', function() {
    return {
        restrict: 'EA',
        scope: { ngSwipeRight: '&' },
        link:function(scope,element,attr){
            element.bind("mouseenter",function(e){
                e.stopPropagation();
               //your logic here...
            });

        }
    };
});

Live example: http://jsfiddle.net/choroshin/dmsw5/

Upvotes: 1

Related Questions