14
14
* The md-swipe-left directive allows you to specify custom behavior when an element is swiped
15
15
* left.
16
16
*
17
+ * ### Notes
18
+ * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
19
+ * reference to the element that actually holds the `md-swipe-left` directive by using `$target.current`
20
+ *
21
+ * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer Tools console while swiping).
22
+ *
17
23
* @usage
18
24
* <hljs lang="html">
19
- * <div md-swipe-left="onSwipeLeft()">Swipe me left!</div>
25
+ * <div md-swipe-left="onSwipeLeft($event, $target )">Swipe me left!</div>
20
26
* </hljs>
21
27
*/
22
28
/**
30
36
* The md-swipe-right directive allows you to specify custom behavior when an element is swiped
31
37
* right.
32
38
*
39
+ * ### Notes
40
+ * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
41
+ * reference to the element that actually holds the `md-swipe-right` directive by using `$target.current`
42
+ *
43
+ * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer Tools console while swiping).
44
+ *
33
45
* @usage
34
46
* <hljs lang="html">
35
- * <div md-swipe-right="onSwipeRight()">Swipe me right!</div>
47
+ * <div md-swipe-right="onSwipeRight($event, $target )">Swipe me right!</div>
36
48
* </hljs>
37
49
*/
38
50
/**
46
58
* The md-swipe-up directive allows you to specify custom behavior when an element is swiped
47
59
* up.
48
60
*
61
+ * ### Notes
62
+ * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
63
+ * reference to the element that actually holds the `md-swipe-up` directive by using `$target.current`
64
+ *
65
+ * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer Tools console while swiping).
66
+ *
49
67
* @usage
50
68
* <hljs lang="html">
51
- * <div md-swipe-up="onSwipeUp()">Swipe me up!</div>
69
+ * <div md-swipe-up="onSwipeUp($event, $target )">Swipe me up!</div>
52
70
* </hljs>
53
71
*/
54
72
/**
62
80
* The md-swipe-down directive allows you to specify custom behavior when an element is swiped
63
81
* down.
64
82
*
83
+ * ### Notes
84
+ * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
85
+ * reference to the element that actually holds the `md-swipe-down` directive by using `$target.current`
86
+ *
87
+ * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer Tools console while swiping).
88
+ *
65
89
* @usage
66
90
* <hljs lang="html">
67
- * <div md-swipe-down="onSwipDown()">Swipe me down!</div>
91
+ * <div md-swipe-down="onSwipDown($event, $target )">Swipe me down!</div>
68
92
* </hljs>
69
93
*/
70
94
@@ -86,7 +110,8 @@ function getDirective(name) {
86
110
function postLink ( scope , element , attr ) {
87
111
var fn = $parse ( attr [ directiveName ] ) ;
88
112
element . on ( eventName , function ( ev ) {
89
- scope . $applyAsync ( function ( ) { fn ( scope , { $event : ev } ) ; } ) ;
113
+ var currentTarget = ev . currentTarget ;
114
+ scope . $applyAsync ( function ( ) { fn ( scope , { $event : ev , $target : { current : currentTarget } } ) ; } ) ;
90
115
} ) ;
91
116
}
92
117
}
0 commit comments