aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Kent2013-10-08 14:49:56 +1100
committerPete Bacon Darwin2013-10-08 12:55:16 +0100
commit507d8021b1c91cc0cefc0418e61b04597ad1030b (patch)
treefb58a88337d65c7d28f3883bcf5f86fd77aa1dfb /src
parentbed08c9c6661d6da5ed6337f194402ea02a8d14c (diff)
downloadangular.js-507d8021b1c91cc0cefc0418e61b04597ad1030b.tar.bz2
fix(ngTouch): add $event to ng-swipe
Existing documentation implies that an Event object should be available as `$event` on swipe directives, which previously was only working for `ng-click`. Closes #4071 Closes #4321
Diffstat (limited to 'src')
-rw-r--r--src/ngTouch/directive/ngSwipe.js8
-rw-r--r--src/ngTouch/swipe.js11
2 files changed, 9 insertions, 10 deletions
diff --git a/src/ngTouch/directive/ngSwipe.js b/src/ngTouch/directive/ngSwipe.js
index a5911f9a..7a468374 100644
--- a/src/ngTouch/directive/ngSwipe.js
+++ b/src/ngTouch/directive/ngSwipe.js
@@ -92,18 +92,18 @@ function makeSwipeDirective(directiveName, direction, eventName) {
}
$swipe.bind(element, {
- 'start': function(coords) {
+ 'start': function(coords, event) {
startCoords = coords;
valid = true;
},
- 'cancel': function() {
+ 'cancel': function(event) {
valid = false;
},
- 'end': function(coords) {
+ 'end': function(coords, event) {
if (validSwipe(coords)) {
scope.$apply(function() {
element.triggerHandler(eventName);
- swipeHandler(scope);
+ swipeHandler(scope, {$event: event});
});
}
}
diff --git a/src/ngTouch/swipe.js b/src/ngTouch/swipe.js
index 0ee4218e..4ad58121 100644
--- a/src/ngTouch/swipe.js
+++ b/src/ngTouch/swipe.js
@@ -83,12 +83,12 @@ ngTouch.factory('$swipe', [function() {
totalX = 0;
totalY = 0;
lastPos = startCoords;
- eventHandlers['start'] && eventHandlers['start'](startCoords);
+ eventHandlers['start'] && eventHandlers['start'](startCoords, event);
});
element.on('touchcancel', function(event) {
active = false;
- eventHandlers['cancel'] && eventHandlers['cancel']();
+ eventHandlers['cancel'] && eventHandlers['cancel'](event);
});
element.on('touchmove mousemove', function(event) {
@@ -116,20 +116,19 @@ ngTouch.factory('$swipe', [function() {
if (totalY > totalX) {
// Allow native scrolling to take over.
active = false;
- eventHandlers['cancel'] && eventHandlers['cancel']();
+ eventHandlers['cancel'] && eventHandlers['cancel'](event);
return;
} else {
// Prevent the browser from scrolling.
event.preventDefault();
-
- eventHandlers['move'] && eventHandlers['move'](coords);
+ eventHandlers['move'] && eventHandlers['move'](coords, event);
}
});
element.on('touchend mouseup', function(event) {
if (!active) return;
active = false;
- eventHandlers['end'] && eventHandlers['end'](getCoordinates(event));
+ eventHandlers['end'] && eventHandlers['end'](getCoordinates(event), event);
});
}
};