1414 * The md-swipe-left directive allows you to specify custom behavior when an element is swiped
1515 * left.
1616 *
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+ *
1723 * @usage
1824 * <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>
2026 * </hljs>
2127 */
2228/**
3036 * The md-swipe-right directive allows you to specify custom behavior when an element is swiped
3137 * right.
3238 *
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+ *
3345 * @usage
3446 * <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>
3648 * </hljs>
3749 */
3850/**
4658 * The md-swipe-up directive allows you to specify custom behavior when an element is swiped
4759 * up.
4860 *
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+ *
4967 * @usage
5068 * <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>
5270 * </hljs>
5371 */
5472/**
6280 * The md-swipe-down directive allows you to specify custom behavior when an element is swiped
6381 * down.
6482 *
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+ *
6589 * @usage
6690 * <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>
6892 * </hljs>
6993 */
7094
@@ -86,7 +110,8 @@ function getDirective(name) {
86110 function postLink ( scope , element , attr ) {
87111 var fn = $parse ( attr [ directiveName ] ) ;
88112 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 } } ) ; } ) ;
90115 } ) ;
91116 }
92117 }
0 commit comments