angular-gem 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/angular-gem/version.rb +1 -1
- data/lib/tasks/copy.rake +22 -11
- data/lib/tasks/tag.rake +2 -11
- data/vendor/assets/javascripts/1.2.0/angular-animate.js +1226 -0
- data/vendor/assets/javascripts/1.2.0/angular-animate.min.js +21 -0
- data/vendor/assets/javascripts/1.2.0/angular-animate.min.js.map +8 -0
- data/vendor/assets/javascripts/{angular-cookies-unstable.js → 1.2.0/angular-cookies.js} +21 -4
- data/vendor/assets/javascripts/1.2.0/angular-cookies.min.js +8 -0
- data/vendor/assets/javascripts/1.2.0/angular-cookies.min.js.map +8 -0
- data/vendor/assets/javascripts/1.2.0/angular-csp.css +24 -0
- data/vendor/assets/javascripts/{angular-loader-unstable.js → 1.2.0/angular-loader.js} +48 -29
- data/vendor/assets/javascripts/1.2.0/angular-loader.min.js +8 -0
- data/vendor/assets/javascripts/1.2.0/angular-loader.min.js.map +8 -0
- data/vendor/assets/javascripts/{angular-mocks-unstable.js → 1.2.0/angular-mocks.js} +460 -216
- data/vendor/assets/javascripts/{angular-resource-unstable.js → 1.2.0/angular-resource.js} +189 -148
- data/vendor/assets/javascripts/1.2.0/angular-resource.min.js +12 -0
- data/vendor/assets/javascripts/1.2.0/angular-resource.min.js.map +8 -0
- data/vendor/assets/javascripts/1.2.0/angular-route.js +880 -0
- data/vendor/assets/javascripts/1.2.0/angular-route.min.js +14 -0
- data/vendor/assets/javascripts/1.2.0/angular-route.min.js.map +8 -0
- data/vendor/assets/javascripts/{angular-sanitize-unstable.js → 1.2.0/angular-sanitize.js} +142 -123
- data/vendor/assets/javascripts/1.2.0/angular-sanitize.min.js +14 -0
- data/vendor/assets/javascripts/1.2.0/angular-sanitize.min.js.map +8 -0
- data/vendor/assets/javascripts/{angular-scenario-unstable.js → 1.2.0/angular-scenario.js} +15978 -12405
- data/vendor/assets/javascripts/{angular-mobile-unstable.js → 1.2.0/angular-touch.js} +214 -111
- data/vendor/assets/javascripts/1.2.0/angular-touch.min.js +13 -0
- data/vendor/assets/javascripts/1.2.0/angular-touch.min.js.map +8 -0
- data/vendor/assets/javascripts/{angular-unstable.js → 1.2.0/angular.js} +10167 -7012
- data/vendor/assets/javascripts/1.2.0/angular.min.js +200 -0
- data/vendor/assets/javascripts/1.2.0/angular.min.js.map +8 -0
- data/vendor/assets/javascripts/1.2.0/errors.json +1 -0
- data/vendor/assets/javascripts/1.2.0/version.json +1 -0
- data/vendor/assets/javascripts/1.2.0/version.txt +1 -0
- data/vendor/assets/javascripts/angular-animate.js +1226 -0
- data/vendor/assets/javascripts/angular-animate.min.js +21 -0
- data/vendor/assets/javascripts/angular-cookies.js +21 -4
- data/vendor/assets/javascripts/angular-cookies.min.js +8 -0
- data/vendor/assets/javascripts/angular-loader.js +63 -17
- data/vendor/assets/javascripts/angular-loader.min.js +8 -0
- data/vendor/assets/javascripts/angular-mocks.js +553 -211
- data/vendor/assets/javascripts/angular-resource.js +268 -147
- data/vendor/assets/javascripts/angular-resource.min.js +12 -0
- data/vendor/assets/javascripts/angular-route.js +880 -0
- data/vendor/assets/javascripts/angular-route.min.js +14 -0
- data/vendor/assets/javascripts/angular-sanitize.js +165 -125
- data/vendor/assets/javascripts/angular-sanitize.min.js +14 -0
- data/vendor/assets/javascripts/angular-scenario.js +16615 -10889
- data/vendor/assets/javascripts/angular-touch.js +563 -0
- data/vendor/assets/javascripts/angular-touch.min.js +13 -0
- data/vendor/assets/javascripts/angular.js +9717 -4533
- data/vendor/assets/javascripts/angular.min.js +200 -0
- metadata +44 -21
- data/test/dummy/log/test.log +0 -2
- data/test/dummy/tmp/cache/assets/D65/250/sprockets%2F54a960d46bb0b354e8bd46fa03f5e0e4 +0 -0
- data/test/dummy/tmp/cache/assets/D6A/FB0/sprockets%2F92721e9941b77adcfdfba3d060622de2 +0 -0
- data/test/dummy/tmp/cache/assets/E07/040/sprockets%2Ff55b8ce9d0f28ce36b768a1c7aeb2ef3 +0 -0
- data/test/tmp/app/assets/javascripts/application.js +0 -5
@@ -1,25 +1,174 @@
|
|
1
1
|
/**
|
2
|
-
* @license AngularJS v1.
|
2
|
+
* @license AngularJS v1.2.0
|
3
3
|
* (c) 2010-2012 Google, Inc. http://angularjs.org
|
4
4
|
* License: MIT
|
5
5
|
*/
|
6
|
-
(function(window, angular, undefined) {
|
7
|
-
'use strict';
|
6
|
+
(function(window, angular, undefined) {'use strict';
|
8
7
|
|
9
8
|
/**
|
10
9
|
* @ngdoc overview
|
11
|
-
* @name
|
10
|
+
* @name ngTouch
|
12
11
|
* @description
|
13
|
-
*
|
14
|
-
*
|
12
|
+
*
|
13
|
+
* # ngTouch
|
14
|
+
*
|
15
|
+
* The `ngTouch` module provides touch events and other helpers for touch-enabled devices.
|
16
|
+
* The implementation is based on jQuery Mobile touch event handling
|
17
|
+
* ([jquerymobile.com](http://jquerymobile.com/)).
|
18
|
+
*
|
19
|
+
* {@installModule touch}
|
20
|
+
*
|
21
|
+
* See {@link ngTouch.$swipe `$swipe`} for usage.
|
22
|
+
*
|
23
|
+
* <div doc-module-components="ngTouch"></div>
|
24
|
+
*
|
15
25
|
*/
|
16
26
|
|
17
|
-
// define
|
18
|
-
|
27
|
+
// define ngTouch module
|
28
|
+
/* global -ngTouch */
|
29
|
+
var ngTouch = angular.module('ngTouch', []);
|
30
|
+
|
31
|
+
/* global ngTouch: false */
|
32
|
+
|
33
|
+
/**
|
34
|
+
* @ngdoc object
|
35
|
+
* @name ngTouch.$swipe
|
36
|
+
*
|
37
|
+
* @description
|
38
|
+
* The `$swipe` service is a service that abstracts the messier details of hold-and-drag swipe
|
39
|
+
* behavior, to make implementing swipe-related directives more convenient.
|
40
|
+
*
|
41
|
+
* Requires the {@link ngTouch `ngTouch`} module to be installed.
|
42
|
+
*
|
43
|
+
* `$swipe` is used by the `ngSwipeLeft` and `ngSwipeRight` directives in `ngTouch`, and by
|
44
|
+
* `ngCarousel` in a separate component.
|
45
|
+
*
|
46
|
+
* # Usage
|
47
|
+
* The `$swipe` service is an object with a single method: `bind`. `bind` takes an element
|
48
|
+
* which is to be watched for swipes, and an object with four handler functions. See the
|
49
|
+
* documentation for `bind` below.
|
50
|
+
*/
|
51
|
+
|
52
|
+
ngTouch.factory('$swipe', [function() {
|
53
|
+
// The total distance in any direction before we make the call on swipe vs. scroll.
|
54
|
+
var MOVE_BUFFER_RADIUS = 10;
|
55
|
+
|
56
|
+
function getCoordinates(event) {
|
57
|
+
var touches = event.touches && event.touches.length ? event.touches : [event];
|
58
|
+
var e = (event.changedTouches && event.changedTouches[0]) ||
|
59
|
+
(event.originalEvent && event.originalEvent.changedTouches &&
|
60
|
+
event.originalEvent.changedTouches[0]) ||
|
61
|
+
touches[0].originalEvent || touches[0];
|
62
|
+
|
63
|
+
return {
|
64
|
+
x: e.clientX,
|
65
|
+
y: e.clientY
|
66
|
+
};
|
67
|
+
}
|
68
|
+
|
69
|
+
return {
|
70
|
+
/**
|
71
|
+
* @ngdoc method
|
72
|
+
* @name ngTouch.$swipe#bind
|
73
|
+
* @methodOf ngTouch.$swipe
|
74
|
+
*
|
75
|
+
* @description
|
76
|
+
* The main method of `$swipe`. It takes an element to be watched for swipe motions, and an
|
77
|
+
* object containing event handlers.
|
78
|
+
*
|
79
|
+
* The four events are `start`, `move`, `end`, and `cancel`. `start`, `move`, and `end`
|
80
|
+
* receive as a parameter a coordinates object of the form `{ x: 150, y: 310 }`.
|
81
|
+
*
|
82
|
+
* `start` is called on either `mousedown` or `touchstart`. After this event, `$swipe` is
|
83
|
+
* watching for `touchmove` or `mousemove` events. These events are ignored until the total
|
84
|
+
* distance moved in either dimension exceeds a small threshold.
|
85
|
+
*
|
86
|
+
* Once this threshold is exceeded, either the horizontal or vertical delta is greater.
|
87
|
+
* - If the horizontal distance is greater, this is a swipe and `move` and `end` events follow.
|
88
|
+
* - If the vertical distance is greater, this is a scroll, and we let the browser take over.
|
89
|
+
* A `cancel` event is sent.
|
90
|
+
*
|
91
|
+
* `move` is called on `mousemove` and `touchmove` after the above logic has determined that
|
92
|
+
* a swipe is in progress.
|
93
|
+
*
|
94
|
+
* `end` is called when a swipe is successfully completed with a `touchend` or `mouseup`.
|
95
|
+
*
|
96
|
+
* `cancel` is called either on a `touchcancel` from the browser, or when we begin scrolling
|
97
|
+
* as described above.
|
98
|
+
*
|
99
|
+
*/
|
100
|
+
bind: function(element, eventHandlers) {
|
101
|
+
// Absolute total movement, used to control swipe vs. scroll.
|
102
|
+
var totalX, totalY;
|
103
|
+
// Coordinates of the start position.
|
104
|
+
var startCoords;
|
105
|
+
// Last event's position.
|
106
|
+
var lastPos;
|
107
|
+
// Whether a swipe is active.
|
108
|
+
var active = false;
|
109
|
+
|
110
|
+
element.on('touchstart mousedown', function(event) {
|
111
|
+
startCoords = getCoordinates(event);
|
112
|
+
active = true;
|
113
|
+
totalX = 0;
|
114
|
+
totalY = 0;
|
115
|
+
lastPos = startCoords;
|
116
|
+
eventHandlers['start'] && eventHandlers['start'](startCoords, event);
|
117
|
+
});
|
118
|
+
|
119
|
+
element.on('touchcancel', function(event) {
|
120
|
+
active = false;
|
121
|
+
eventHandlers['cancel'] && eventHandlers['cancel'](event);
|
122
|
+
});
|
123
|
+
|
124
|
+
element.on('touchmove mousemove', function(event) {
|
125
|
+
if (!active) return;
|
126
|
+
|
127
|
+
// Android will send a touchcancel if it thinks we're starting to scroll.
|
128
|
+
// So when the total distance (+ or - or both) exceeds 10px in either direction,
|
129
|
+
// we either:
|
130
|
+
// - On totalX > totalY, we send preventDefault() and treat this as a swipe.
|
131
|
+
// - On totalY > totalX, we let the browser handle it as a scroll.
|
132
|
+
|
133
|
+
if (!startCoords) return;
|
134
|
+
var coords = getCoordinates(event);
|
135
|
+
|
136
|
+
totalX += Math.abs(coords.x - lastPos.x);
|
137
|
+
totalY += Math.abs(coords.y - lastPos.y);
|
138
|
+
|
139
|
+
lastPos = coords;
|
140
|
+
|
141
|
+
if (totalX < MOVE_BUFFER_RADIUS && totalY < MOVE_BUFFER_RADIUS) {
|
142
|
+
return;
|
143
|
+
}
|
144
|
+
|
145
|
+
// One of totalX or totalY has exceeded the buffer, so decide on swipe vs. scroll.
|
146
|
+
if (totalY > totalX) {
|
147
|
+
// Allow native scrolling to take over.
|
148
|
+
active = false;
|
149
|
+
eventHandlers['cancel'] && eventHandlers['cancel'](event);
|
150
|
+
return;
|
151
|
+
} else {
|
152
|
+
// Prevent the browser from scrolling.
|
153
|
+
event.preventDefault();
|
154
|
+
eventHandlers['move'] && eventHandlers['move'](coords, event);
|
155
|
+
}
|
156
|
+
});
|
157
|
+
|
158
|
+
element.on('touchend mouseup', function(event) {
|
159
|
+
if (!active) return;
|
160
|
+
active = false;
|
161
|
+
eventHandlers['end'] && eventHandlers['end'](getCoordinates(event), event);
|
162
|
+
});
|
163
|
+
}
|
164
|
+
};
|
165
|
+
}]);
|
166
|
+
|
167
|
+
/* global ngTouch: false */
|
19
168
|
|
20
169
|
/**
|
21
170
|
* @ngdoc directive
|
22
|
-
* @name
|
171
|
+
* @name ngTouch.directive:ngClick
|
23
172
|
*
|
24
173
|
* @description
|
25
174
|
* A more powerful replacement for the default ngClick designed to be used on touchscreen
|
@@ -27,6 +176,8 @@ var ngMobile = angular.module('ngMobile', []);
|
|
27
176
|
* the click event. This version handles them immediately, and then prevents the
|
28
177
|
* following click event from propagating.
|
29
178
|
*
|
179
|
+
* Requires the {@link ngTouch `ngTouch`} module to be installed.
|
180
|
+
*
|
30
181
|
* This directive can fall back to using an ordinary click event, and so works on desktop
|
31
182
|
* browsers as well as mobile.
|
32
183
|
*
|
@@ -48,7 +199,7 @@ var ngMobile = angular.module('ngMobile', []);
|
|
48
199
|
</doc:example>
|
49
200
|
*/
|
50
201
|
|
51
|
-
|
202
|
+
ngTouch.config(['$provide', function($provide) {
|
52
203
|
$provide.decorator('ngClickDirective', ['$delegate', function($delegate) {
|
53
204
|
// drop the default ngClick directive
|
54
205
|
$delegate.shift();
|
@@ -56,7 +207,7 @@ ngMobile.config(['$provide', function($provide) {
|
|
56
207
|
}]);
|
57
208
|
}]);
|
58
209
|
|
59
|
-
|
210
|
+
ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
60
211
|
function($parse, $timeout, $rootElement) {
|
61
212
|
var TAP_DURATION = 750; // Shorter than 750ms is a tap, longer is a taphold or drag.
|
62
213
|
var MOVE_TOLERANCE = 12; // 12px seems to work in most mobile browsers.
|
@@ -152,6 +303,9 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
152
303
|
// If we didn't find an allowable region, bust the click.
|
153
304
|
event.stopPropagation();
|
154
305
|
event.preventDefault();
|
306
|
+
|
307
|
+
// Blur focused form elements
|
308
|
+
event.target && event.target.blur();
|
155
309
|
}
|
156
310
|
|
157
311
|
|
@@ -202,7 +356,7 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
202
356
|
element.removeClass(ACTIVE_CLASS_NAME);
|
203
357
|
}
|
204
358
|
|
205
|
-
element.
|
359
|
+
element.on('touchstart', function(event) {
|
206
360
|
tapping = true;
|
207
361
|
tapElement = event.target ? event.target : event.srcElement; // IE uses srcElement.
|
208
362
|
// Hack for Safari, which can target text nodes instead of containers.
|
@@ -220,15 +374,15 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
220
374
|
touchStartY = e.clientY;
|
221
375
|
});
|
222
376
|
|
223
|
-
element.
|
377
|
+
element.on('touchmove', function(event) {
|
224
378
|
resetState();
|
225
379
|
});
|
226
380
|
|
227
|
-
element.
|
381
|
+
element.on('touchcancel', function(event) {
|
228
382
|
resetState();
|
229
383
|
});
|
230
384
|
|
231
|
-
element.
|
385
|
+
element.on('touchend', function(event) {
|
232
386
|
var diff = Date.now() - startTime;
|
233
387
|
|
234
388
|
var touches = (event.changedTouches && event.changedTouches.length) ? event.changedTouches :
|
@@ -249,10 +403,9 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
249
403
|
tapElement.blur();
|
250
404
|
}
|
251
405
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
});
|
406
|
+
if (!angular.isDefined(attr.disabled) || attr.disabled === false) {
|
407
|
+
element.triggerHandler('click', [event]);
|
408
|
+
}
|
256
409
|
}
|
257
410
|
|
258
411
|
resetState();
|
@@ -262,34 +415,42 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
262
415
|
// something else nearby.
|
263
416
|
element.onclick = function(event) { };
|
264
417
|
|
265
|
-
//
|
266
|
-
//
|
267
|
-
// desktop
|
268
|
-
|
418
|
+
// Actual click handler.
|
419
|
+
// There are three different kinds of clicks, only two of which reach this point.
|
420
|
+
// - On desktop browsers without touch events, their clicks will always come here.
|
421
|
+
// - On mobile browsers, the simulated "fast" click will call this.
|
422
|
+
// - But the browser's follow-up slow click will be "busted" before it reaches this handler.
|
423
|
+
// Therefore it's safe to use this directive on both mobile and desktop.
|
424
|
+
element.on('click', function(event, touchend) {
|
269
425
|
scope.$apply(function() {
|
270
|
-
clickHandler(scope, {$event: event});
|
426
|
+
clickHandler(scope, {$event: (touchend || event)});
|
271
427
|
});
|
272
428
|
});
|
273
429
|
|
274
|
-
element.
|
430
|
+
element.on('mousedown', function(event) {
|
275
431
|
element.addClass(ACTIVE_CLASS_NAME);
|
276
432
|
});
|
277
433
|
|
278
|
-
element.
|
434
|
+
element.on('mousemove mouseup', function(event) {
|
279
435
|
element.removeClass(ACTIVE_CLASS_NAME);
|
280
436
|
});
|
281
437
|
|
282
438
|
};
|
283
439
|
}]);
|
284
440
|
|
441
|
+
/* global ngTouch: false */
|
442
|
+
|
285
443
|
/**
|
286
444
|
* @ngdoc directive
|
287
|
-
* @name
|
445
|
+
* @name ngTouch.directive:ngSwipeLeft
|
288
446
|
*
|
289
447
|
* @description
|
290
448
|
* Specify custom behavior when an element is swiped to the left on a touchscreen device.
|
291
449
|
* A leftward swipe is a quick, right-to-left slide of the finger.
|
292
|
-
* Though ngSwipeLeft is designed for touch-based devices, it will work with a mouse click and drag
|
450
|
+
* Though ngSwipeLeft is designed for touch-based devices, it will work with a mouse click and drag
|
451
|
+
* too.
|
452
|
+
*
|
453
|
+
* Requires the {@link ngTouch `ngTouch`} module to be installed.
|
293
454
|
*
|
294
455
|
* @element ANY
|
295
456
|
* @param {expression} ngSwipeLeft {@link guide/expression Expression} to evaluate
|
@@ -311,12 +472,15 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
311
472
|
|
312
473
|
/**
|
313
474
|
* @ngdoc directive
|
314
|
-
* @name
|
475
|
+
* @name ngTouch.directive:ngSwipeRight
|
315
476
|
*
|
316
477
|
* @description
|
317
478
|
* Specify custom behavior when an element is swiped to the right on a touchscreen device.
|
318
479
|
* A rightward swipe is a quick, left-to-right slide of the finger.
|
319
|
-
* Though ngSwipeRight is designed for touch-based devices, it will work with a mouse click and drag
|
480
|
+
* Though ngSwipeRight is designed for touch-based devices, it will work with a mouse click and drag
|
481
|
+
* too.
|
482
|
+
*
|
483
|
+
* Requires the {@link ngTouch `ngTouch`} module to be installed.
|
320
484
|
*
|
321
485
|
* @element ANY
|
322
486
|
* @param {expression} ngSwipeRight {@link guide/expression Expression} to evaluate
|
@@ -336,37 +500,21 @@ ngMobile.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
336
500
|
</doc:example>
|
337
501
|
*/
|
338
502
|
|
339
|
-
function makeSwipeDirective(directiveName, direction) {
|
340
|
-
|
503
|
+
function makeSwipeDirective(directiveName, direction, eventName) {
|
504
|
+
ngTouch.directive(directiveName, ['$parse', '$swipe', function($parse, $swipe) {
|
341
505
|
// The maximum vertical delta for a swipe should be less than 75px.
|
342
506
|
var MAX_VERTICAL_DISTANCE = 75;
|
343
507
|
// Vertical distance should not be more than a fraction of the horizontal distance.
|
344
508
|
var MAX_VERTICAL_RATIO = 0.3;
|
345
509
|
// At least a 30px lateral motion is necessary for a swipe.
|
346
510
|
var MIN_HORIZONTAL_DISTANCE = 30;
|
347
|
-
// The total distance in any direction before we make the call on swipe vs. scroll.
|
348
|
-
var MOVE_BUFFER_RADIUS = 10;
|
349
|
-
|
350
|
-
function getCoordinates(event) {
|
351
|
-
var touches = event.touches && event.touches.length ? event.touches : [event];
|
352
|
-
var e = (event.changedTouches && event.changedTouches[0]) ||
|
353
|
-
(event.originalEvent && event.originalEvent.changedTouches &&
|
354
|
-
event.originalEvent.changedTouches[0]) ||
|
355
|
-
touches[0].originalEvent || touches[0];
|
356
|
-
|
357
|
-
return {
|
358
|
-
x: e.clientX,
|
359
|
-
y: e.clientY
|
360
|
-
};
|
361
|
-
}
|
362
511
|
|
363
512
|
return function(scope, element, attr) {
|
364
513
|
var swipeHandler = $parse(attr[directiveName]);
|
514
|
+
|
365
515
|
var startCoords, valid;
|
366
|
-
var totalX, totalY;
|
367
|
-
var lastX, lastY;
|
368
516
|
|
369
|
-
function validSwipe(
|
517
|
+
function validSwipe(coords) {
|
370
518
|
// Check that it's within the coordinates.
|
371
519
|
// Absolute vertical distance must be within tolerances.
|
372
520
|
// Horizontal distance, we take the current X - the starting X.
|
@@ -376,7 +524,6 @@ function makeSwipeDirective(directiveName, direction) {
|
|
376
524
|
// illegal ones a negative delta.
|
377
525
|
// Therefore this delta must be positive, and larger than the minimum.
|
378
526
|
if (!startCoords) return false;
|
379
|
-
var coords = getCoordinates(event);
|
380
527
|
var deltaY = Math.abs(coords.y - startCoords.y);
|
381
528
|
var deltaX = (coords.x - startCoords.x) * direction;
|
382
529
|
return valid && // Short circuit for already-invalidated swipes.
|
@@ -386,65 +533,21 @@ function makeSwipeDirective(directiveName, direction) {
|
|
386
533
|
deltaY / deltaX < MAX_VERTICAL_RATIO;
|
387
534
|
}
|
388
535
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
lastY = startCoords.y;
|
396
|
-
});
|
397
|
-
|
398
|
-
element.bind('touchcancel', function(event) {
|
399
|
-
valid = false;
|
400
|
-
});
|
401
|
-
|
402
|
-
element.bind('touchmove mousemove', function(event) {
|
403
|
-
if (!valid) return;
|
404
|
-
|
405
|
-
// Android will send a touchcancel if it thinks we're starting to scroll.
|
406
|
-
// So when the total distance (+ or - or both) exceeds 10px in either direction,
|
407
|
-
// we either:
|
408
|
-
// - On totalX > totalY, we send preventDefault() and treat this as a swipe.
|
409
|
-
// - On totalY > totalX, we let the browser handle it as a scroll.
|
410
|
-
|
411
|
-
// Invalidate a touch while it's in progress if it strays too far away vertically.
|
412
|
-
// We don't want a scroll down and back up while drifting sideways to be a swipe just
|
413
|
-
// because you happened to end up vertically close in the end.
|
414
|
-
if (!startCoords) return;
|
415
|
-
var coords = getCoordinates(event);
|
416
|
-
|
417
|
-
if (Math.abs(coords.y - startCoords.y) > MAX_VERTICAL_DISTANCE) {
|
536
|
+
$swipe.bind(element, {
|
537
|
+
'start': function(coords, event) {
|
538
|
+
startCoords = coords;
|
539
|
+
valid = true;
|
540
|
+
},
|
541
|
+
'cancel': function(event) {
|
418
542
|
valid = false;
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
if (totalX < MOVE_BUFFER_RADIUS && totalY < MOVE_BUFFER_RADIUS) {
|
429
|
-
return;
|
430
|
-
}
|
431
|
-
|
432
|
-
// One of totalX or totalY has exceeded the buffer, so decide on swipe vs. scroll.
|
433
|
-
if (totalY > totalX) {
|
434
|
-
valid = false;
|
435
|
-
return;
|
436
|
-
} else {
|
437
|
-
event.preventDefault();
|
438
|
-
}
|
439
|
-
});
|
440
|
-
|
441
|
-
element.bind('touchend mouseup', function(event) {
|
442
|
-
if (validSwipe(event)) {
|
443
|
-
// Prevent this swipe from bubbling up to any other elements with ngSwipes.
|
444
|
-
event.stopPropagation();
|
445
|
-
scope.$apply(function() {
|
446
|
-
swipeHandler(scope, {$event:event});
|
447
|
-
});
|
543
|
+
},
|
544
|
+
'end': function(coords, event) {
|
545
|
+
if (validSwipe(coords)) {
|
546
|
+
scope.$apply(function() {
|
547
|
+
element.triggerHandler(eventName);
|
548
|
+
swipeHandler(scope, {$event: event});
|
549
|
+
});
|
550
|
+
}
|
448
551
|
}
|
449
552
|
});
|
450
553
|
};
|
@@ -452,8 +555,8 @@ function makeSwipeDirective(directiveName, direction) {
|
|
452
555
|
}
|
453
556
|
|
454
557
|
// Left is negative X-coordinate, right is positive.
|
455
|
-
makeSwipeDirective('ngSwipeLeft', -1);
|
456
|
-
makeSwipeDirective('ngSwipeRight', 1);
|
558
|
+
makeSwipeDirective('ngSwipeLeft', -1, 'swipeleft');
|
559
|
+
makeSwipeDirective('ngSwipeRight', 1, 'swiperight');
|
457
560
|
|
458
561
|
|
459
562
|
|