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