|
|
|
@ -1,6 +1,6 @@
@@ -1,6 +1,6 @@
|
|
|
|
|
/** |
|
|
|
|
* @license AngularJS v1.4.7 |
|
|
|
|
* (c) 2010-2015 Google, Inc. http://angularjs.org
|
|
|
|
|
* @license AngularJS v1.3.7 |
|
|
|
|
* (c) 2010-2014 Google, Inc. http://angularjs.org
|
|
|
|
|
* License: MIT |
|
|
|
|
*/ |
|
|
|
|
(function(window, angular, undefined) {'use strict'; |
|
|
|
@ -27,10 +27,6 @@
@@ -27,10 +27,6 @@
|
|
|
|
|
/* global -ngTouch */ |
|
|
|
|
var ngTouch = angular.module('ngTouch', []); |
|
|
|
|
|
|
|
|
|
function nodeName_(element) { |
|
|
|
|
return angular.lowercase(element.nodeName || (element[0] && element[0].nodeName)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* global ngTouch: false */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -71,9 +67,11 @@ ngTouch.factory('$swipe', [function() {
@@ -71,9 +67,11 @@ ngTouch.factory('$swipe', [function() {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function getCoordinates(event) { |
|
|
|
|
var originalEvent = event.originalEvent || event; |
|
|
|
|
var touches = originalEvent.touches && originalEvent.touches.length ? originalEvent.touches : [originalEvent]; |
|
|
|
|
var e = (originalEvent.changedTouches && originalEvent.changedTouches[0]) || touches[0]; |
|
|
|
|
var touches = event.touches && event.touches.length ? event.touches : [event]; |
|
|
|
|
var e = (event.changedTouches && event.changedTouches[0]) || |
|
|
|
|
(event.originalEvent && event.originalEvent.changedTouches && |
|
|
|
|
event.originalEvent.changedTouches[0]) || |
|
|
|
|
touches[0].originalEvent || touches[0]; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
x: e.clientX, |
|
|
|
@ -105,8 +103,7 @@ ngTouch.factory('$swipe', [function() {
@@ -105,8 +103,7 @@ ngTouch.factory('$swipe', [function() {
|
|
|
|
|
* `$swipe` will listen for `mouse` and `touch` events. |
|
|
|
|
* |
|
|
|
|
* The four events are `start`, `move`, `end`, and `cancel`. `start`, `move`, and `end` |
|
|
|
|
* receive as a parameter a coordinates object of the form `{ x: 150, y: 310 }` and the raw |
|
|
|
|
* `event`. `cancel` receives the raw `event` as its single parameter. |
|
|
|
|
* receive as a parameter a coordinates object of the form `{ x: 150, y: 310 }`. |
|
|
|
|
* |
|
|
|
|
* `start` is called on either `mousedown` or `touchstart`. After this event, `$swipe` is |
|
|
|
|
* watching for `touchmove` or `mousemove` events. These events are ignored until the total |
|
|
|
@ -196,9 +193,7 @@ ngTouch.factory('$swipe', [function() {
@@ -196,9 +193,7 @@ ngTouch.factory('$swipe', [function() {
|
|
|
|
|
}; |
|
|
|
|
}]); |
|
|
|
|
|
|
|
|
|
/* global ngTouch: false, |
|
|
|
|
nodeName_: false |
|
|
|
|
*/ |
|
|
|
|
/* global ngTouch: false */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @ngdoc directive |
|
|
|
@ -264,7 +259,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
@@ -264,7 +259,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
|
|
|
// double-tapping, and then fire a click event.
|
|
|
|
|
//
|
|
|
|
|
// This delay sucks and makes mobile apps feel unresponsive.
|
|
|
|
|
// So we detect touchstart, touchcancel and touchend ourselves and determine when
|
|
|
|
|
// So we detect touchstart, touchmove, touchcancel and touchend ourselves and determine when
|
|
|
|
|
// the user has tapped on something.
|
|
|
|
|
//
|
|
|
|
|
// What happens when the browser then generates a click event?
|
|
|
|
@ -276,7 +271,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
@@ -276,7 +271,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
|
|
|
// So the sequence for a tap is:
|
|
|
|
|
// - global touchstart: Sets an "allowable region" at the point touched.
|
|
|
|
|
// - element's touchstart: Starts a touch
|
|
|
|
|
// (- touchcancel ends the touch, no click follows)
|
|
|
|
|
// (- touchmove or touchcancel ends the touch, no click follows)
|
|
|
|
|
// - element's touchend: Determines if the tap is valid (didn't move too far away, didn't hold
|
|
|
|
|
// too long) and fires the user's tap handler. The touchend also calls preventGhostClick().
|
|
|
|
|
// - preventGhostClick() removes the allowable region the global touchstart created.
|
|
|
|
@ -340,7 +335,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
@@ -340,7 +335,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
|
|
|
lastLabelClickCoordinates = null; |
|
|
|
|
} |
|
|
|
|
// remember label click coordinates to prevent click busting of trigger click event on input
|
|
|
|
|
if (nodeName_(event.target) === 'label') { |
|
|
|
|
if (event.target.tagName.toLowerCase() === 'label') { |
|
|
|
|
lastLabelClickCoordinates = [x, y]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -356,7 +351,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
@@ -356,7 +351,7 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
|
|
|
|
// Blur focused form elements
|
|
|
|
|
event.target && event.target.blur && event.target.blur(); |
|
|
|
|
event.target && event.target.blur(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -419,14 +414,16 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
@@ -419,14 +414,16 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
|
|
|
|
|
|
|
|
startTime = Date.now(); |
|
|
|
|
|
|
|
|
|
// Use jQuery originalEvent
|
|
|
|
|
var originalEvent = event.originalEvent || event; |
|
|
|
|
var touches = originalEvent.touches && originalEvent.touches.length ? originalEvent.touches : [originalEvent]; |
|
|
|
|
var e = touches[0]; |
|
|
|
|
var touches = event.touches && event.touches.length ? event.touches : [event]; |
|
|
|
|
var e = touches[0].originalEvent || touches[0]; |
|
|
|
|
touchStartX = e.clientX; |
|
|
|
|
touchStartY = e.clientY; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
element.on('touchmove', function(event) { |
|
|
|
|
resetState(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
element.on('touchcancel', function(event) { |
|
|
|
|
resetState(); |
|
|
|
|
}); |
|
|
|
@ -434,12 +431,9 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
@@ -434,12 +431,9 @@ ngTouch.directive('ngClick', ['$parse', '$timeout', '$rootElement',
|
|
|
|
|
element.on('touchend', function(event) { |
|
|
|
|
var diff = Date.now() - startTime; |
|
|
|
|
|
|
|
|
|
// Use jQuery originalEvent
|
|
|
|
|
var originalEvent = event.originalEvent || event; |
|
|
|
|
var touches = (originalEvent.changedTouches && originalEvent.changedTouches.length) ? |
|
|
|
|
originalEvent.changedTouches : |
|
|
|
|
((originalEvent.touches && originalEvent.touches.length) ? originalEvent.touches : [originalEvent]); |
|
|
|
|
var e = touches[0]; |
|
|
|
|
var touches = (event.changedTouches && event.changedTouches.length) ? event.changedTouches : |
|
|
|
|
((event.touches && event.touches.length) ? event.touches : [event]); |
|
|
|
|
var e = touches[0].originalEvent || touches[0]; |
|
|
|
|
var x = e.clientX; |
|
|
|
|
var y = e.clientY; |
|
|
|
|
var dist = Math.sqrt(Math.pow(x - touchStartX, 2) + Math.pow(y - touchStartY, 2)); |
|
|
|
@ -625,4 +619,4 @@ makeSwipeDirective('ngSwipeRight', 1, 'swiperight');
@@ -625,4 +619,4 @@ makeSwipeDirective('ngSwipeRight', 1, 'swiperight');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})(window, window.angular); |
|
|
|
|
})(window, window.angular); |