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