From ab189142988043d0513bb796c3b54ca7d07f242d Mon Sep 17 00:00:00 2001 From: Braden Shepherdson Date: Thu, 25 Jul 2013 15:23:10 -0700 Subject: feat(ngMobile): emit 'swipeleft' and 'swiperight' events Similar to ngMobile clicks, these events were not capturable by other directives. Now they emit 'swipeleft' and 'swiperight' events that can be follow with element.on('swipeleft', ...). --- src/ngMobile/directive/ngSwipe.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ngMobile/directive/ngSwipe.js b/src/ngMobile/directive/ngSwipe.js index e68e45da..42389542 100644 --- a/src/ngMobile/directive/ngSwipe.js +++ b/src/ngMobile/directive/ngSwipe.js @@ -54,7 +54,7 @@ */ -function makeSwipeDirective(directiveName, direction) { +function makeSwipeDirective(directiveName, direction, eventName) { ngMobile.directive(directiveName, ['$parse', '$swipe', function($parse, $swipe) { // The maximum vertical delta for a swipe should be less than 75px. var MAX_VERTICAL_DISTANCE = 75; @@ -98,6 +98,7 @@ function makeSwipeDirective(directiveName, direction) { 'end': function(coords) { if (validSwipe(coords)) { scope.$apply(function() { + element.triggerHandler(eventName); swipeHandler(scope); }); } @@ -108,6 +109,6 @@ function makeSwipeDirective(directiveName, direction) { } // Left is negative X-coordinate, right is positive. -makeSwipeDirective('ngSwipeLeft', -1); -makeSwipeDirective('ngSwipeRight', 1); +makeSwipeDirective('ngSwipeLeft', -1, 'swipeleft'); +makeSwipeDirective('ngSwipeRight', 1, 'swiperight'); -- cgit v1.2.3