-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgesture.js
More file actions
303 lines (265 loc) · 5.35 KB
/
Copy pathgesture.js
File metadata and controls
303 lines (265 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
var GESTURE_DIRECTIVES = 'onHold onTap onDoubleTap onTouch onRelease onDragStart onDrag onDragEnd onDragUp onDragRight onDragDown onDragLeft onSwipe onSwipeUp onSwipeRight onSwipeDown onSwipeLeft'.split(' ');
GESTURE_DIRECTIVES.forEach(function(name) {
IonicModule.directive(name, gestureDirective(name));
});
/**
* @ngdoc directive
* @name onHold
* @module ionic
* @restrict A
*
* @description
* Touch stays at the same location for 500ms. Similar to long touch events available for AngularJS and jQuery.
*
* @usage
* ```html
* <button on-hold="onHold()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onTap
* @module ionic
* @restrict A
*
* @description
* Quick touch at a location. If the duration of the touch goes
* longer than 250ms it is no longer a tap gesture.
*
* @usage
* ```html
* <button on-tap="onTap()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDoubleTap
* @module ionic
* @restrict A
*
* @description
* Double tap touch at a location.
*
* @usage
* ```html
* <button on-double-tap="onDoubleTap()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onTouch
* @module ionic
* @restrict A
*
* @description
* Called immediately when the user first begins a touch. This
* gesture does not wait for a touchend/mouseup.
*
* @usage
* ```html
* <button on-touch="onTouch()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onRelease
* @module ionic
* @restrict A
*
* @description
* Called when the user ends a touch.
*
* @usage
* ```html
* <button on-release="onRelease()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDragStart
* @module ionic
* @restrict A
*
* @description
* Called when a drag gesture has started.
*
* @usage
* ```html
* <button on-drag-start="onDragStart()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDrag
* @module ionic
* @restrict A
*
* @description
* Move with one touch around on the page. Blocking the scrolling when
* moving left and right is a good practice. When all the drag events are
* blocking you disable scrolling on that area.
*
* @usage
* ```html
* <button on-drag="onDrag()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDragEnd
* @module ionic
* @restrict A
*
* @description
* Called when a drag gesture has ended.
*
* @usage
* ```html
* <button on-drag-end="onDragEnd()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDragUp
* @module ionic
* @restrict A
*
* @description
* Called when the element is dragged up.
*
* @usage
* ```html
* <button on-drag-up="onDragUp()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDragRight
* @module ionic
* @restrict A
*
* @description
* Called when the element is dragged to the right.
*
* @usage
* ```html
* <button on-drag-right="onDragRight()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDragDown
* @module ionic
* @restrict A
*
* @description
* Called when the element is dragged down.
*
* @usage
* ```html
* <button on-drag-down="onDragDown()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onDragLeft
* @module ionic
* @restrict A
*
* @description
* Called when the element is dragged to the left.
*
* @usage
* ```html
* <button on-drag-left="onDragLeft()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onSwipe
* @module ionic
* @restrict A
*
* @description
* Called when a moving touch has a high velocity in any direction.
*
* @usage
* ```html
* <button on-swipe="onSwipe()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onSwipeUp
* @module ionic
* @restrict A
*
* @description
* Called when a moving touch has a high velocity moving up.
*
* @usage
* ```html
* <button on-swipe-up="onSwipeUp()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onSwipeRight
* @module ionic
* @restrict A
*
* @description
* Called when a moving touch has a high velocity moving to the right.
*
* @usage
* ```html
* <button on-swipe-right="onSwipeRight()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onSwipeDown
* @module ionic
* @restrict A
*
* @description
* Called when a moving touch has a high velocity moving down.
*
* @usage
* ```html
* <button on-swipe-down="onSwipeDown()" class="button">Test</button>
* ```
*/
/**
* @ngdoc directive
* @name onSwipeLeft
* @module ionic
* @restrict A
*
* @description
* Called when a moving touch has a high velocity moving to the left.
*
* @usage
* ```html
* <button on-swipe-left="onSwipeLeft()" class="button">Test</button>
* ```
*/
function gestureDirective(directiveName) {
return ['$ionicGesture', '$parse', function($ionicGesture, $parse) {
var eventType = directiveName.substr(2).toLowerCase();
return function(scope, element, attr) {
var fn = $parse( attr[directiveName] );
var listener = function(ev) {
scope.$apply(function() {
fn(scope, {
$event: ev
});
});
};
var gesture = $ionicGesture.on(eventType, listener, element);
scope.$on('$destroy', function() {
$ionicGesture.off(gesture, eventType, listener);
});
};
}];
}