source: trip-planner-front/node_modules/angular-material/modules/js/swipe/swipe.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*!
2 * AngularJS Material Design
3 * https://github.com/angular/material
4 * @license MIT
5 * v1.2.3
6 */
7(function( window, angular, undefined ){
8"use strict";
9
10/**
11 * @ngdoc module
12 * @name material.components.swipe
13 * @description Swipe module!
14 */
15/**
16 * @ngdoc directive
17 * @module material.components.swipe
18 * @name mdSwipeLeft
19 *
20 * @restrict A
21 *
22 * @description
23 * The md-swipe-left directive allows you to specify custom behavior when an element is swiped
24 * left.
25 *
26 * ### Notes
27 * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
28 * reference to the element that actually holds the `md-swipe-left` directive by using
29 * `$target.current`
30 *
31 * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer
32 * Tools console while swiping).
33 *
34 * @usage
35 * <hljs lang="html">
36 * <div md-swipe-left="onSwipeLeft($event, $target)">Swipe me left!</div>
37 * </hljs>
38 */
39/**
40 * @ngdoc directive
41 * @module material.components.swipe
42 * @name mdSwipeRight
43 *
44 * @restrict A
45 *
46 * @description
47 * The md-swipe-right directive allows you to specify custom behavior when an element is swiped
48 * right.
49 *
50 * ### Notes
51 * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
52 * reference to the element that actually holds the `md-swipe-right` directive by using
53 * `$target.current`
54 *
55 * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer
56 * Tools console while swiping).
57 *
58 * @usage
59 * <hljs lang="html">
60 * <div md-swipe-right="onSwipeRight($event, $target)">Swipe me right!</div>
61 * </hljs>
62 */
63/**
64 * @ngdoc directive
65 * @module material.components.swipe
66 * @name mdSwipeUp
67 *
68 * @restrict A
69 *
70 * @description
71 * The md-swipe-up directive allows you to specify custom behavior when an element is swiped
72 * up.
73 *
74 * ### Notes
75 * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
76 * reference to the element that actually holds the `md-swipe-up` directive by using
77 * `$target.current`
78 *
79 * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer
80 * Tools console while swiping).
81 *
82 * @usage
83 * <hljs lang="html">
84 * <div md-swipe-up="onSwipeUp($event, $target)">Swipe me up!</div>
85 * </hljs>
86 */
87/**
88 * @ngdoc directive
89 * @module material.components.swipe
90 * @name mdSwipeDown
91 *
92 * @restrict A
93 *
94 * @description
95 * The md-swipe-down directive allows you to specify custom behavior when an element is swiped
96 * down.
97 *
98 * ### Notes
99 * - The `$event.currentTarget` of the swiped element will be `null`, but you can get a
100 * reference to the element that actually holds the `md-swipe-down` directive by using
101 * `$target.current`
102 *
103 * > You can see this in action on the <a ng-href="demo/swipe">demo page</a> (Look at the Developer
104 * Tools console while swiping).
105 *
106 * @usage
107 * <hljs lang="html">
108 * <div md-swipe-down="onSwipeDown($event, $target)">Swipe me down!</div>
109 * </hljs>
110 */
111
112angular.module('material.components.swipe', ['material.core'])
113 .directive('mdSwipeLeft', getDirective('SwipeLeft'))
114 .directive('mdSwipeRight', getDirective('SwipeRight'))
115 .directive('mdSwipeUp', getDirective('SwipeUp'))
116 .directive('mdSwipeDown', getDirective('SwipeDown'));
117
118function getDirective(name) {
119 DirectiveFactory['$inject'] = ["$parse"];
120 var directiveName = 'md' + name;
121 var eventName = '$md.' + name.toLowerCase();
122
123 return DirectiveFactory;
124
125 /* ngInject */
126 function DirectiveFactory($parse) {
127 return { restrict: 'A', link: postLink };
128 function postLink(scope, element, attr) {
129 var fn = $parse(attr[directiveName]);
130 element.on(eventName, function(ev) {
131 var currentTarget = ev.currentTarget;
132 scope.$applyAsync(function() { fn(scope, { $event: ev, $target: { current: currentTarget } }); });
133 });
134 }
135 }
136}
137
138
139
140})(window, window.angular);
Note: See TracBrowser for help on using the repository browser.