|
|
/**
|
|
|
* jQuery WeUI V1.2.1
|
|
|
* By 言川
|
|
|
* http://lihongxun945.github.io/jquery-weui/
|
|
|
* jQuery WeUI V1.2.1
|
|
|
* By 言川
|
|
|
* http://lihongxun945.github.io/jquery-weui/
|
|
|
*/
|
|
|
/* global $:true */
|
|
|
/* global WebKitCSSMatrix:true */
|
...
|
...
|
@@ -577,27 +577,27 @@ |
|
|
(function(window, document, exportName, undefined) {
|
|
|
'use strict';
|
|
|
|
|
|
var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
|
|
var TEST_ELEMENT = document.createElement('div');
|
|
|
var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
|
|
var TEST_ELEMENT = document.createElement('div');
|
|
|
|
|
|
var TYPE_FUNCTION = 'function';
|
|
|
var TYPE_FUNCTION = 'function';
|
|
|
|
|
|
var round = Math.round;
|
|
|
var abs = Math.abs;
|
|
|
var now = Date.now;
|
|
|
var round = Math.round;
|
|
|
var abs = Math.abs;
|
|
|
var now = Date.now;
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* set a timeout with a given scope
|
|
|
* @param {Function} fn
|
|
|
* @param {Number} timeout
|
|
|
* @param {Object} context
|
|
|
* @returns {number}
|
|
|
*/
|
|
|
function setTimeoutContext(fn, timeout, context) {
|
|
|
function setTimeoutContext(fn, timeout, context) {
|
|
|
return setTimeout(bindFn(fn, context), timeout);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* if the argument is an array, we want to execute the fn on each entry
|
|
|
* if it aint an array we don't want to do a thing.
|
|
|
* this is used by all the methods that accept a single and array argument.
|
...
|
...
|
@@ -606,21 +606,21 @@ function setTimeoutContext(fn, timeout, context) { |
|
|
* @param {Object} [context]
|
|
|
* @returns {Boolean}
|
|
|
*/
|
|
|
function invokeArrayArg(arg, fn, context) {
|
|
|
function invokeArrayArg(arg, fn, context) {
|
|
|
if (Array.isArray(arg)) {
|
|
|
each(arg, context[fn], context);
|
|
|
return true;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* walk objects and arrays
|
|
|
* @param {Object} obj
|
|
|
* @param {Function} iterator
|
|
|
* @param {Object} context
|
|
|
*/
|
|
|
function each(obj, iterator, context) {
|
|
|
function each(obj, iterator, context) {
|
|
|
var i;
|
|
|
|
|
|
if (!obj) {
|
...
|
...
|
@@ -640,16 +640,16 @@ function each(obj, iterator, context) { |
|
|
obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* wrap a method with a deprecation warning and stack trace
|
|
|
* @param {Function} method
|
|
|
* @param {String} name
|
|
|
* @param {String} message
|
|
|
* @returns {Function} A new function wrapping the supplied method.
|
|
|
*/
|
|
|
function deprecate(method, name, message) {
|
|
|
function deprecate(method, name, message) {
|
|
|
var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
|
|
return function() {
|
|
|
var e = new Error('get-stack-trace');
|
...
|
...
|
@@ -663,17 +663,17 @@ function deprecate(method, name, message) { |
|
|
}
|
|
|
return method.apply(this, arguments);
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* extend object.
|
|
|
* means that properties in dest will be overwritten by the ones in src.
|
|
|
* @param {Object} target
|
|
|
* @param {...Object} objects_to_assign
|
|
|
* @returns {Object} target
|
|
|
*/
|
|
|
var assign;
|
|
|
if (typeof Object.assign !== 'function') {
|
|
|
var assign;
|
|
|
if (typeof Object.assign !== 'function') {
|
|
|
assign = function assign(target) {
|
|
|
if (target === undefined || target === null) {
|
|
|
throw new TypeError('Cannot convert undefined or null to object');
|
...
|
...
|
@@ -692,11 +692,11 @@ if (typeof Object.assign !== 'function') { |
|
|
}
|
|
|
return output;
|
|
|
};
|
|
|
} else {
|
|
|
} else {
|
|
|
assign = Object.assign;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* extend object.
|
|
|
* means that properties in dest will be overwritten by the ones in src.
|
|
|
* @param {Object} dest
|
...
|
...
|
@@ -704,7 +704,7 @@ if (typeof Object.assign !== 'function') { |
|
|
* @param {Boolean} [merge=false]
|
|
|
* @returns {Object} dest
|
|
|
*/
|
|
|
var extend = deprecate(function extend(dest, src, merge) {
|
|
|
var extend = deprecate(function extend(dest, src, merge) {
|
|
|
var keys = Object.keys(src);
|
|
|
var i = 0;
|
|
|
while (i < keys.length) {
|
...
|
...
|
@@ -714,26 +714,26 @@ var extend = deprecate(function extend(dest, src, merge) { |
|
|
i++;
|
|
|
}
|
|
|
return dest;
|
|
|
}, 'extend', 'Use `assign`.');
|
|
|
}, 'extend', 'Use `assign`.');
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* merge the values from src in the dest.
|
|
|
* means that properties that exist in dest will not be overwritten by src
|
|
|
* @param {Object} dest
|
|
|
* @param {Object} src
|
|
|
* @returns {Object} dest
|
|
|
*/
|
|
|
var merge = deprecate(function merge(dest, src) {
|
|
|
var merge = deprecate(function merge(dest, src) {
|
|
|
return extend(dest, src, true);
|
|
|
}, 'merge', 'Use `assign`.');
|
|
|
}, 'merge', 'Use `assign`.');
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* simple class inheritance
|
|
|
* @param {Function} child
|
|
|
* @param {Function} base
|
|
|
* @param {Object} [properties]
|
|
|
*/
|
|
|
function inherit(child, base, properties) {
|
|
|
function inherit(child, base, properties) {
|
|
|
var baseP = base.prototype,
|
|
|
childP;
|
|
|
|
...
|
...
|
@@ -744,76 +744,76 @@ function inherit(child, base, properties) { |
|
|
if (properties) {
|
|
|
assign(childP, properties);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* simple function bind
|
|
|
* @param {Function} fn
|
|
|
* @param {Object} context
|
|
|
* @returns {Function}
|
|
|
*/
|
|
|
function bindFn(fn, context) {
|
|
|
function bindFn(fn, context) {
|
|
|
return function boundFn() {
|
|
|
return fn.apply(context, arguments);
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* let a boolean value also be a function that must return a boolean
|
|
|
* this first item in args will be used as the context
|
|
|
* @param {Boolean|Function} val
|
|
|
* @param {Array} [args]
|
|
|
* @returns {Boolean}
|
|
|
*/
|
|
|
function boolOrFn(val, args) {
|
|
|
function boolOrFn(val, args) {
|
|
|
if (typeof val == TYPE_FUNCTION) {
|
|
|
return val.apply(args ? args[0] || undefined : undefined, args);
|
|
|
}
|
|
|
return val;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* use the val2 when val1 is undefined
|
|
|
* @param {*} val1
|
|
|
* @param {*} val2
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
function ifUndefined(val1, val2) {
|
|
|
function ifUndefined(val1, val2) {
|
|
|
return (val1 === undefined) ? val2 : val1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* addEventListener with multiple events at once
|
|
|
* @param {EventTarget} target
|
|
|
* @param {String} types
|
|
|
* @param {Function} handler
|
|
|
*/
|
|
|
function addEventListeners(target, types, handler) {
|
|
|
function addEventListeners(target, types, handler) {
|
|
|
each(splitStr(types), function(type) {
|
|
|
target.addEventListener(type, handler, false);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* removeEventListener with multiple events at once
|
|
|
* @param {EventTarget} target
|
|
|
* @param {String} types
|
|
|
* @param {Function} handler
|
|
|
*/
|
|
|
function removeEventListeners(target, types, handler) {
|
|
|
function removeEventListeners(target, types, handler) {
|
|
|
each(splitStr(types), function(type) {
|
|
|
target.removeEventListener(type, handler, false);
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* find if a node is in the given parent
|
|
|
* @method hasParent
|
|
|
* @param {HTMLElement} node
|
|
|
* @param {HTMLElement} parent
|
|
|
* @return {Boolean} found
|
|
|
*/
|
|
|
function hasParent(node, parent) {
|
|
|
function hasParent(node, parent) {
|
|
|
while (node) {
|
|
|
if (node == parent) {
|
|
|
return true;
|
...
|
...
|
@@ -821,35 +821,35 @@ function hasParent(node, parent) { |
|
|
node = node.parentNode;
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* small indexOf wrapper
|
|
|
* @param {String} str
|
|
|
* @param {String} find
|
|
|
* @returns {Boolean} found
|
|
|
*/
|
|
|
function inStr(str, find) {
|
|
|
function inStr(str, find) {
|
|
|
return str.indexOf(find) > -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* split string on whitespace
|
|
|
* @param {String} str
|
|
|
* @returns {Array} words
|
|
|
*/
|
|
|
function splitStr(str) {
|
|
|
function splitStr(str) {
|
|
|
return str.trim().split(/\s+/g);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* find if a array contains the object using indexOf or a simple polyFill
|
|
|
* @param {Array} src
|
|
|
* @param {String} find
|
|
|
* @param {String} [findByKey]
|
|
|
* @return {Boolean|Number} false when not found, or the index
|
|
|
*/
|
|
|
function inArray(src, find, findByKey) {
|
|
|
function inArray(src, find, findByKey) {
|
|
|
if (src.indexOf && !findByKey) {
|
|
|
return src.indexOf(find);
|
|
|
} else {
|
...
|
...
|
@@ -862,25 +862,25 @@ function inArray(src, find, findByKey) { |
|
|
}
|
|
|
return -1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* convert array-like objects to real arrays
|
|
|
* @param {Object} obj
|
|
|
* @returns {Array}
|
|
|
*/
|
|
|
function toArray(obj) {
|
|
|
function toArray(obj) {
|
|
|
return Array.prototype.slice.call(obj, 0);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* unique array with objects based on a key (like 'id') or just by the array's value
|
|
|
* @param {Array} src [{id:1},{id:2},{id:1}]
|
|
|
* @param {String} [key]
|
|
|
* @param {Boolean} [sort=False]
|
|
|
* @returns {Array} [{id:1},{id:2}]
|
|
|
*/
|
|
|
function uniqueArray(src, key, sort) {
|
|
|
function uniqueArray(src, key, sort) {
|
|
|
var results = [];
|
|
|
var values = [];
|
|
|
var i = 0;
|
...
|
...
|
@@ -905,15 +905,15 @@ function uniqueArray(src, key, sort) { |
|
|
}
|
|
|
|
|
|
return results;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get the prefixed property
|
|
|
* @param {Object} obj
|
|
|
* @param {String} property
|
|
|
* @returns {String|Undefined} prefixed
|
|
|
*/
|
|
|
function prefixed(obj, property) {
|
|
|
function prefixed(obj, property) {
|
|
|
var prefix, prop;
|
|
|
var camelProp = property[0].toUpperCase() + property.slice(1);
|
|
|
|
...
|
...
|
@@ -928,66 +928,66 @@ function prefixed(obj, property) { |
|
|
i++;
|
|
|
}
|
|
|
return undefined;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get a unique id
|
|
|
* @returns {number} uniqueId
|
|
|
*/
|
|
|
var _uniqueId = 1;
|
|
|
function uniqueId() {
|
|
|
var _uniqueId = 1;
|
|
|
function uniqueId() {
|
|
|
return _uniqueId++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get the window object of an element
|
|
|
* @param {HTMLElement} element
|
|
|
* @returns {DocumentView|Window}
|
|
|
*/
|
|
|
function getWindowForElement(element) {
|
|
|
function getWindowForElement(element) {
|
|
|
var doc = element.ownerDocument || element;
|
|
|
return (doc.defaultView || doc.parentWindow || window);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
|
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
|
|
|
|
var SUPPORT_TOUCH = ('ontouchstart' in window);
|
|
|
var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
|
|
|
var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
|
|
var SUPPORT_TOUCH = ('ontouchstart' in window);
|
|
|
var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
|
|
|
var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
|
|
|
|
|
var INPUT_TYPE_TOUCH = 'touch';
|
|
|
var INPUT_TYPE_PEN = 'pen';
|
|
|
var INPUT_TYPE_MOUSE = 'mouse';
|
|
|
var INPUT_TYPE_KINECT = 'kinect';
|
|
|
var INPUT_TYPE_TOUCH = 'touch';
|
|
|
var INPUT_TYPE_PEN = 'pen';
|
|
|
var INPUT_TYPE_MOUSE = 'mouse';
|
|
|
var INPUT_TYPE_KINECT = 'kinect';
|
|
|
|
|
|
var COMPUTE_INTERVAL = 25;
|
|
|
var COMPUTE_INTERVAL = 25;
|
|
|
|
|
|
var INPUT_START = 1;
|
|
|
var INPUT_MOVE = 2;
|
|
|
var INPUT_END = 4;
|
|
|
var INPUT_CANCEL = 8;
|
|
|
var INPUT_START = 1;
|
|
|
var INPUT_MOVE = 2;
|
|
|
var INPUT_END = 4;
|
|
|
var INPUT_CANCEL = 8;
|
|
|
|
|
|
var DIRECTION_NONE = 1;
|
|
|
var DIRECTION_LEFT = 2;
|
|
|
var DIRECTION_RIGHT = 4;
|
|
|
var DIRECTION_UP = 8;
|
|
|
var DIRECTION_DOWN = 16;
|
|
|
var DIRECTION_NONE = 1;
|
|
|
var DIRECTION_LEFT = 2;
|
|
|
var DIRECTION_RIGHT = 4;
|
|
|
var DIRECTION_UP = 8;
|
|
|
var DIRECTION_DOWN = 16;
|
|
|
|
|
|
var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
|
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
|
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
|
|
var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
|
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
|
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
|
|
|
|
|
var PROPS_XY = ['x', 'y'];
|
|
|
var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
|
|
var PROPS_XY = ['x', 'y'];
|
|
|
var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* create new input type manager
|
|
|
* @param {Manager} manager
|
|
|
* @param {Function} callback
|
|
|
* @returns {Input}
|
|
|
* @constructor
|
|
|
*/
|
|
|
function Input(manager, callback) {
|
|
|
function Input(manager, callback) {
|
|
|
var self = this;
|
|
|
this.manager = manager;
|
|
|
this.callback = callback;
|
...
|
...
|
@@ -1004,9 +1004,9 @@ function Input(manager, callback) { |
|
|
|
|
|
this.init();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Input.prototype = {
|
|
|
Input.prototype = {
|
|
|
/**
|
|
|
* should handle the inputEvent data and trigger the callback
|
|
|
* @virtual
|
...
|
...
|
@@ -1030,15 +1030,15 @@ Input.prototype = { |
|
|
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
|
|
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
|
}
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* create new input type manager
|
|
|
* called by the Manager constructor
|
|
|
* @param {Hammer} manager
|
|
|
* @returns {Input}
|
|
|
*/
|
|
|
function createInputInstance(manager) {
|
|
|
function createInputInstance(manager) {
|
|
|
var Type;
|
|
|
var inputClass = manager.options.inputClass;
|
|
|
|
...
|
...
|
@@ -1054,15 +1054,15 @@ function createInputInstance(manager) { |
|
|
Type = TouchMouseInput;
|
|
|
}
|
|
|
return new (Type)(manager, inputHandler);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* handle input events
|
|
|
* @param {Manager} manager
|
|
|
* @param {String} eventType
|
|
|
* @param {Object} input
|
|
|
*/
|
|
|
function inputHandler(manager, eventType, input) {
|
|
|
function inputHandler(manager, eventType, input) {
|
|
|
var pointersLen = input.pointers.length;
|
|
|
var changedPointersLen = input.changedPointers.length;
|
|
|
var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
...
|
...
|
@@ -1087,14 +1087,14 @@ function inputHandler(manager, eventType, input) { |
|
|
|
|
|
manager.recognize(input);
|
|
|
manager.session.prevInput = input;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* extend the data with some usable properties like scale, rotate, velocity etc
|
|
|
* @param {Object} manager
|
|
|
* @param {Object} input
|
|
|
*/
|
|
|
function computeInputData(manager, input) {
|
|
|
function computeInputData(manager, input) {
|
|
|
var session = manager.session;
|
|
|
var pointers = input.pointers;
|
|
|
var pointersLength = pointers.length;
|
...
|
...
|
@@ -1144,9 +1144,9 @@ function computeInputData(manager, input) { |
|
|
target = input.srcEvent.target;
|
|
|
}
|
|
|
input.target = target;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function computeDeltaXY(session, input) {
|
|
|
function computeDeltaXY(session, input) {
|
|
|
var center = input.center;
|
|
|
var offset = session.offsetDelta || {};
|
|
|
var prevDelta = session.prevDelta || {};
|
...
|
...
|
@@ -1166,14 +1166,14 @@ function computeDeltaXY(session, input) { |
|
|
|
|
|
input.deltaX = prevDelta.x + (center.x - offset.x);
|
|
|
input.deltaY = prevDelta.y + (center.y - offset.y);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* velocity is calculated every x ms
|
|
|
* @param {Object} session
|
|
|
* @param {Object} input
|
|
|
*/
|
|
|
function computeIntervalInputData(session, input) {
|
|
|
function computeIntervalInputData(session, input) {
|
|
|
var last = session.lastInterval || input,
|
|
|
deltaTime = input.timeStamp - last.timeStamp,
|
|
|
velocity, velocityX, velocityY, direction;
|
...
|
...
|
@@ -1201,14 +1201,14 @@ function computeIntervalInputData(session, input) { |
|
|
input.velocityX = velocityX;
|
|
|
input.velocityY = velocityY;
|
|
|
input.direction = direction;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* create a simple clone from the input used for storage of firstInput and firstMultiple
|
|
|
* @param {Object} input
|
|
|
* @returns {Object} clonedInputData
|
|
|
*/
|
|
|
function simpleCloneInputData(input) {
|
|
|
function simpleCloneInputData(input) {
|
|
|
// make a simple copy of the pointers because we will get a reference if we don't
|
|
|
// we only need clientXY for the calculations
|
|
|
var pointers = [];
|
...
|
...
|
@@ -1228,14 +1228,14 @@ function simpleCloneInputData(input) { |
|
|
deltaX: input.deltaX,
|
|
|
deltaY: input.deltaY
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get the center of all the pointers
|
|
|
* @param {Array} pointers
|
|
|
* @return {Object} center contains `x` and `y` properties
|
|
|
*/
|
|
|
function getCenter(pointers) {
|
|
|
function getCenter(pointers) {
|
|
|
var pointersLength = pointers.length;
|
|
|
|
|
|
// no need to loop when only one touch
|
...
|
...
|
@@ -1257,29 +1257,29 @@ function getCenter(pointers) { |
|
|
x: round(x / pointersLength),
|
|
|
y: round(y / pointersLength)
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* calculate the velocity between two points. unit is in px per ms.
|
|
|
* @param {Number} deltaTime
|
|
|
* @param {Number} x
|
|
|
* @param {Number} y
|
|
|
* @return {Object} velocity `x` and `y`
|
|
|
*/
|
|
|
function getVelocity(deltaTime, x, y) {
|
|
|
function getVelocity(deltaTime, x, y) {
|
|
|
return {
|
|
|
x: x / deltaTime || 0,
|
|
|
y: y / deltaTime || 0
|
|
|
};
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get the direction between two points
|
|
|
* @param {Number} x
|
|
|
* @param {Number} y
|
|
|
* @return {Number} direction
|
|
|
*/
|
|
|
function getDirection(x, y) {
|
|
|
function getDirection(x, y) {
|
|
|
if (x === y) {
|
|
|
return DIRECTION_NONE;
|
|
|
}
|
...
|
...
|
@@ -1288,16 +1288,16 @@ function getDirection(x, y) { |
|
|
return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
|
|
}
|
|
|
return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* calculate the absolute distance between two points
|
|
|
* @param {Object} p1 {x, y}
|
|
|
* @param {Object} p2 {x, y}
|
|
|
* @param {Array} [props] containing x and y keys
|
|
|
* @return {Number} distance
|
|
|
*/
|
|
|
function getDistance(p1, p2, props) {
|
|
|
function getDistance(p1, p2, props) {
|
|
|
if (!props) {
|
|
|
props = PROPS_XY;
|
|
|
}
|
...
|
...
|
@@ -1305,69 +1305,69 @@ function getDistance(p1, p2, props) { |
|
|
y = p2[props[1]] - p1[props[1]];
|
|
|
|
|
|
return Math.sqrt((x * x) + (y * y));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* calculate the angle between two coordinates
|
|
|
* @param {Object} p1
|
|
|
* @param {Object} p2
|
|
|
* @param {Array} [props] containing x and y keys
|
|
|
* @return {Number} angle
|
|
|
*/
|
|
|
function getAngle(p1, p2, props) {
|
|
|
function getAngle(p1, p2, props) {
|
|
|
if (!props) {
|
|
|
props = PROPS_XY;
|
|
|
}
|
|
|
var x = p2[props[0]] - p1[props[0]],
|
|
|
y = p2[props[1]] - p1[props[1]];
|
|
|
return Math.atan2(y, x) * 180 / Math.PI;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* calculate the rotation degrees between two pointersets
|
|
|
* @param {Array} start array of pointers
|
|
|
* @param {Array} end array of pointers
|
|
|
* @return {Number} rotation
|
|
|
*/
|
|
|
function getRotation(start, end) {
|
|
|
function getRotation(start, end) {
|
|
|
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* calculate the scale factor between two pointersets
|
|
|
* no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
|
|
|
* @param {Array} start array of pointers
|
|
|
* @param {Array} end array of pointers
|
|
|
* @return {Number} scale
|
|
|
*/
|
|
|
function getScale(start, end) {
|
|
|
function getScale(start, end) {
|
|
|
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var MOUSE_INPUT_MAP = {
|
|
|
var MOUSE_INPUT_MAP = {
|
|
|
mousedown: INPUT_START,
|
|
|
mousemove: INPUT_MOVE,
|
|
|
mouseup: INPUT_END
|
|
|
};
|
|
|
};
|
|
|
|
|
|
var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
|
|
var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
|
|
var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
|
|
var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Mouse events input
|
|
|
* @constructor
|
|
|
* @extends Input
|
|
|
*/
|
|
|
function MouseInput() {
|
|
|
function MouseInput() {
|
|
|
this.evEl = MOUSE_ELEMENT_EVENTS;
|
|
|
this.evWin = MOUSE_WINDOW_EVENTS;
|
|
|
|
|
|
this.pressed = false; // mousedown state
|
|
|
|
|
|
Input.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(MouseInput, Input, {
|
|
|
inherit(MouseInput, Input, {
|
|
|
/**
|
|
|
* handle mouse events
|
|
|
* @param {Object} ev
|
...
|
...
|
@@ -1400,48 +1400,48 @@ inherit(MouseInput, Input, { |
|
|
srcEvent: ev
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
var POINTER_INPUT_MAP = {
|
|
|
var POINTER_INPUT_MAP = {
|
|
|
pointerdown: INPUT_START,
|
|
|
pointermove: INPUT_MOVE,
|
|
|
pointerup: INPUT_END,
|
|
|
pointercancel: INPUT_CANCEL,
|
|
|
pointerout: INPUT_CANCEL
|
|
|
};
|
|
|
};
|
|
|
|
|
|
// in IE10 the pointer types is defined as an enum
|
|
|
var IE10_POINTER_TYPE_ENUM = {
|
|
|
var IE10_POINTER_TYPE_ENUM = {
|
|
|
2: INPUT_TYPE_TOUCH,
|
|
|
3: INPUT_TYPE_PEN,
|
|
|
4: INPUT_TYPE_MOUSE,
|
|
|
5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
|
|
|
};
|
|
|
};
|
|
|
|
|
|
var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
|
|
var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
|
|
var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
|
|
var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
|
|
|
|
|
// IE10 has prefixed support, and case-sensitive
|
|
|
if (window.MSPointerEvent && !window.PointerEvent) {
|
|
|
if (window.MSPointerEvent && !window.PointerEvent) {
|
|
|
POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
|
|
POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Pointer events input
|
|
|
* @constructor
|
|
|
* @extends Input
|
|
|
*/
|
|
|
function PointerEventInput() {
|
|
|
function PointerEventInput() {
|
|
|
this.evEl = POINTER_ELEMENT_EVENTS;
|
|
|
this.evWin = POINTER_WINDOW_EVENTS;
|
|
|
|
|
|
Input.apply(this, arguments);
|
|
|
|
|
|
this.store = (this.manager.session.pointerEvents = []);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(PointerEventInput, Input, {
|
|
|
inherit(PointerEventInput, Input, {
|
|
|
/**
|
|
|
* handle mouse events
|
|
|
* @param {Object} ev
|
...
|
...
|
@@ -1489,32 +1489,32 @@ inherit(PointerEventInput, Input, { |
|
|
store.splice(storeIndex, 1);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
var SINGLE_TOUCH_INPUT_MAP = {
|
|
|
var SINGLE_TOUCH_INPUT_MAP = {
|
|
|
touchstart: INPUT_START,
|
|
|
touchmove: INPUT_MOVE,
|
|
|
touchend: INPUT_END,
|
|
|
touchcancel: INPUT_CANCEL
|
|
|
};
|
|
|
};
|
|
|
|
|
|
var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
|
|
var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
|
|
var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
|
|
var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Touch events input
|
|
|
* @constructor
|
|
|
* @extends Input
|
|
|
*/
|
|
|
function SingleTouchInput() {
|
|
|
function SingleTouchInput() {
|
|
|
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
|
|
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
|
|
this.started = false;
|
|
|
|
|
|
Input.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(SingleTouchInput, Input, {
|
|
|
inherit(SingleTouchInput, Input, {
|
|
|
handler: function TEhandler(ev) {
|
|
|
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
|
|
|
...
|
...
|
@@ -1541,15 +1541,15 @@ inherit(SingleTouchInput, Input, { |
|
|
srcEvent: ev
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* @this {TouchInput}
|
|
|
* @param {Object} ev
|
|
|
* @param {Number} type flag
|
|
|
* @returns {undefined|Array} [all, changed]
|
|
|
*/
|
|
|
function normalizeSingleTouches(ev, type) {
|
|
|
function normalizeSingleTouches(ev, type) {
|
|
|
var all = toArray(ev.touches);
|
|
|
var changed = toArray(ev.changedTouches);
|
|
|
|
...
|
...
|
@@ -1558,30 +1558,30 @@ function normalizeSingleTouches(ev, type) { |
|
|
}
|
|
|
|
|
|
return [all, changed];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var TOUCH_INPUT_MAP = {
|
|
|
var TOUCH_INPUT_MAP = {
|
|
|
touchstart: INPUT_START,
|
|
|
touchmove: INPUT_MOVE,
|
|
|
touchend: INPUT_END,
|
|
|
touchcancel: INPUT_CANCEL
|
|
|
};
|
|
|
};
|
|
|
|
|
|
var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
|
|
var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Multi-user touch events input
|
|
|
* @constructor
|
|
|
* @extends Input
|
|
|
*/
|
|
|
function TouchInput() {
|
|
|
function TouchInput() {
|
|
|
this.evTarget = TOUCH_TARGET_EVENTS;
|
|
|
this.targetIds = {};
|
|
|
|
|
|
Input.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(TouchInput, Input, {
|
|
|
inherit(TouchInput, Input, {
|
|
|
handler: function MTEhandler(ev) {
|
|
|
var type = TOUCH_INPUT_MAP[ev.type];
|
|
|
var touches = getTouches.call(this, ev, type);
|
...
|
...
|
@@ -1596,15 +1596,15 @@ inherit(TouchInput, Input, { |
|
|
srcEvent: ev
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* @this {TouchInput}
|
|
|
* @param {Object} ev
|
|
|
* @param {Number} type flag
|
|
|
* @returns {undefined|Array} [all, changed]
|
|
|
*/
|
|
|
function getTouches(ev, type) {
|
|
|
function getTouches(ev, type) {
|
|
|
var allTouches = toArray(ev.touches);
|
|
|
var targetIds = this.targetIds;
|
|
|
|
...
|
...
|
@@ -1657,9 +1657,9 @@ function getTouches(ev, type) { |
|
|
uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
|
|
|
changedTargetTouches
|
|
|
];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Combined touch and mouse input
|
|
|
*
|
|
|
* Touch has a higher priority then mouse, and while touching no mouse events are allowed.
|
...
|
...
|
@@ -1669,10 +1669,10 @@ function getTouches(ev, type) { |
|
|
* @extends Input
|
|
|
*/
|
|
|
|
|
|
var DEDUP_TIMEOUT = 2500;
|
|
|
var DEDUP_DISTANCE = 25;
|
|
|
var DEDUP_TIMEOUT = 2500;
|
|
|
var DEDUP_DISTANCE = 25;
|
|
|
|
|
|
function TouchMouseInput() {
|
|
|
function TouchMouseInput() {
|
|
|
Input.apply(this, arguments);
|
|
|
|
|
|
var handler = bindFn(this.handler, this);
|
...
|
...
|
@@ -1681,9 +1681,9 @@ function TouchMouseInput() { |
|
|
|
|
|
this.primaryTouch = null;
|
|
|
this.lastTouches = [];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(TouchMouseInput, Input, {
|
|
|
inherit(TouchMouseInput, Input, {
|
|
|
/**
|
|
|
* handle mouse and touch events
|
|
|
* @param {Hammer} manager
|
...
|
...
|
@@ -1715,18 +1715,18 @@ inherit(TouchMouseInput, Input, { |
|
|
this.touch.destroy();
|
|
|
this.mouse.destroy();
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
function recordTouches(eventType, eventData) {
|
|
|
function recordTouches(eventType, eventData) {
|
|
|
if (eventType & INPUT_START) {
|
|
|
this.primaryTouch = eventData.changedPointers[0].identifier;
|
|
|
setLastTouch.call(this, eventData);
|
|
|
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
|
|
setLastTouch.call(this, eventData);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function setLastTouch(eventData) {
|
|
|
function setLastTouch(eventData) {
|
|
|
var touch = eventData.changedPointers[0];
|
|
|
|
|
|
if (touch.identifier === this.primaryTouch) {
|
...
|
...
|
@@ -1741,9 +1741,9 @@ function setLastTouch(eventData) { |
|
|
};
|
|
|
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function isSyntheticEvent(eventData) {
|
|
|
function isSyntheticEvent(eventData) {
|
|
|
var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
|
|
for (var i = 0; i < this.lastTouches.length; i++) {
|
|
|
var t = this.lastTouches[i];
|
...
|
...
|
@@ -1753,33 +1753,33 @@ function isSyntheticEvent(eventData) { |
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
|
|
var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
|
|
var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
|
|
var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
|
|
|
|
|
// magical touchAction value
|
|
|
var TOUCH_ACTION_COMPUTE = 'compute';
|
|
|
var TOUCH_ACTION_AUTO = 'auto';
|
|
|
var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
|
|
|
var TOUCH_ACTION_NONE = 'none';
|
|
|
var TOUCH_ACTION_PAN_X = 'pan-x';
|
|
|
var TOUCH_ACTION_PAN_Y = 'pan-y';
|
|
|
var TOUCH_ACTION_MAP = getTouchActionProps();
|
|
|
var TOUCH_ACTION_COMPUTE = 'compute';
|
|
|
var TOUCH_ACTION_AUTO = 'auto';
|
|
|
var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
|
|
|
var TOUCH_ACTION_NONE = 'none';
|
|
|
var TOUCH_ACTION_PAN_X = 'pan-x';
|
|
|
var TOUCH_ACTION_PAN_Y = 'pan-y';
|
|
|
var TOUCH_ACTION_MAP = getTouchActionProps();
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Touch Action
|
|
|
* sets the touchAction property or uses the js alternative
|
|
|
* @param {Manager} manager
|
|
|
* @param {String} value
|
|
|
* @constructor
|
|
|
*/
|
|
|
function TouchAction(manager, value) {
|
|
|
function TouchAction(manager, value) {
|
|
|
this.manager = manager;
|
|
|
this.set(value);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TouchAction.prototype = {
|
|
|
TouchAction.prototype = {
|
|
|
/**
|
|
|
* set the touchAction value on the element or enable the polyfill
|
|
|
* @param {String} value
|
...
|
...
|
@@ -1868,14 +1868,14 @@ TouchAction.prototype = { |
|
|
this.manager.session.prevented = true;
|
|
|
srcEvent.preventDefault();
|
|
|
}
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* when the touchActions are collected they are not a valid value, so we need to clean things up. *
|
|
|
* @param {String} actions
|
|
|
* @returns {*}
|
|
|
*/
|
|
|
function cleanTouchActions(actions) {
|
|
|
function cleanTouchActions(actions) {
|
|
|
// none
|
|
|
if (inStr(actions, TOUCH_ACTION_NONE)) {
|
|
|
return TOUCH_ACTION_NONE;
|
...
|
...
|
@@ -1903,9 +1903,9 @@ function cleanTouchActions(actions) { |
|
|
}
|
|
|
|
|
|
return TOUCH_ACTION_AUTO;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function getTouchActionProps() {
|
|
|
function getTouchActionProps() {
|
|
|
if (!NATIVE_TOUCH_ACTION) {
|
|
|
return false;
|
|
|
}
|
...
|
...
|
@@ -1918,9 +1918,9 @@ function getTouchActionProps() { |
|
|
touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
|
|
});
|
|
|
return touchMap;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Recognizer flow explained; *
|
|
|
* All recognizers have the initial state of POSSIBLE when a input session starts.
|
|
|
* The definition of a input session is from the first input until the last input, with all it's movement in it. *
|
...
|
...
|
@@ -1947,21 +1947,21 @@ function getTouchActionProps() { |
|
|
* |
|
|
|
* Ended/Recognized
|
|
|
*/
|
|
|
var STATE_POSSIBLE = 1;
|
|
|
var STATE_BEGAN = 2;
|
|
|
var STATE_CHANGED = 4;
|
|
|
var STATE_ENDED = 8;
|
|
|
var STATE_RECOGNIZED = STATE_ENDED;
|
|
|
var STATE_CANCELLED = 16;
|
|
|
var STATE_FAILED = 32;
|
|
|
var STATE_POSSIBLE = 1;
|
|
|
var STATE_BEGAN = 2;
|
|
|
var STATE_CHANGED = 4;
|
|
|
var STATE_ENDED = 8;
|
|
|
var STATE_RECOGNIZED = STATE_ENDED;
|
|
|
var STATE_CANCELLED = 16;
|
|
|
var STATE_FAILED = 32;
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Recognizer
|
|
|
* Every recognizer needs to extend from this class.
|
|
|
* @constructor
|
|
|
* @param {Object} options
|
|
|
*/
|
|
|
function Recognizer(options) {
|
|
|
function Recognizer(options) {
|
|
|
this.options = assign({}, this.defaults, options || {});
|
|
|
|
|
|
this.id = uniqueId();
|
...
|
...
|
@@ -1975,9 +1975,9 @@ function Recognizer(options) { |
|
|
|
|
|
this.simultaneous = {};
|
|
|
this.requireFail = [];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Recognizer.prototype = {
|
|
|
Recognizer.prototype = {
|
|
|
/**
|
|
|
* @virtual
|
|
|
* @type {Object}
|
...
|
...
|
@@ -2196,14 +2196,14 @@ Recognizer.prototype = { |
|
|
* @virtual
|
|
|
*/
|
|
|
reset: function() { }
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get a usable string, used as event postfix
|
|
|
* @param {Const} state
|
|
|
* @returns {String} state
|
|
|
*/
|
|
|
function stateStr(state) {
|
|
|
function stateStr(state) {
|
|
|
if (state & STATE_CANCELLED) {
|
|
|
return 'cancel';
|
|
|
} else if (state & STATE_ENDED) {
|
...
|
...
|
@@ -2214,14 +2214,14 @@ function stateStr(state) { |
|
|
return 'start';
|
|
|
}
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* direction cons to string
|
|
|
* @param {Const} direction
|
|
|
* @returns {String}
|
|
|
*/
|
|
|
function directionStr(direction) {
|
|
|
function directionStr(direction) {
|
|
|
if (direction == DIRECTION_DOWN) {
|
|
|
return 'down';
|
|
|
} else if (direction == DIRECTION_UP) {
|
...
|
...
|
@@ -2232,32 +2232,32 @@ function directionStr(direction) { |
|
|
return 'right';
|
|
|
}
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* get a recognizer by name if it is bound to a manager
|
|
|
* @param {Recognizer|String} otherRecognizer
|
|
|
* @param {Recognizer} recognizer
|
|
|
* @returns {Recognizer}
|
|
|
*/
|
|
|
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
|
|
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
|
|
var manager = recognizer.manager;
|
|
|
if (manager) {
|
|
|
return manager.get(otherRecognizer);
|
|
|
}
|
|
|
return otherRecognizer;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* This recognizer is just used as a base for the simple attribute recognizers.
|
|
|
* @constructor
|
|
|
* @extends Recognizer
|
|
|
*/
|
|
|
function AttrRecognizer() {
|
|
|
function AttrRecognizer() {
|
|
|
Recognizer.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(AttrRecognizer, Recognizer, {
|
|
|
inherit(AttrRecognizer, Recognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof AttrRecognizer
|
...
|
...
|
@@ -2307,22 +2307,22 @@ inherit(AttrRecognizer, Recognizer, { |
|
|
}
|
|
|
return STATE_FAILED;
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Pan
|
|
|
* Recognized when the pointer is down and moved in the allowed direction.
|
|
|
* @constructor
|
|
|
* @extends AttrRecognizer
|
|
|
*/
|
|
|
function PanRecognizer() {
|
|
|
function PanRecognizer() {
|
|
|
AttrRecognizer.apply(this, arguments);
|
|
|
|
|
|
this.pX = null;
|
|
|
this.pY = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(PanRecognizer, AttrRecognizer, {
|
|
|
inherit(PanRecognizer, AttrRecognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof PanRecognizer
|
...
|
...
|
@@ -2387,19 +2387,19 @@ inherit(PanRecognizer, AttrRecognizer, { |
|
|
}
|
|
|
this._super.emit.call(this, input);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Pinch
|
|
|
* Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
|
|
|
* @constructor
|
|
|
* @extends AttrRecognizer
|
|
|
*/
|
|
|
function PinchRecognizer() {
|
|
|
function PinchRecognizer() {
|
|
|
AttrRecognizer.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(PinchRecognizer, AttrRecognizer, {
|
|
|
inherit(PinchRecognizer, AttrRecognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof PinchRecognizer
|
...
|
...
|
@@ -2426,22 +2426,22 @@ inherit(PinchRecognizer, AttrRecognizer, { |
|
|
}
|
|
|
this._super.emit.call(this, input);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Press
|
|
|
* Recognized when the pointer is down for x ms without any movement.
|
|
|
* @constructor
|
|
|
* @extends Recognizer
|
|
|
*/
|
|
|
function PressRecognizer() {
|
|
|
function PressRecognizer() {
|
|
|
Recognizer.apply(this, arguments);
|
|
|
|
|
|
this._timer = null;
|
|
|
this._input = null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(PressRecognizer, Recognizer, {
|
|
|
inherit(PressRecognizer, Recognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof PressRecognizer
|
...
|
...
|
@@ -2497,19 +2497,19 @@ inherit(PressRecognizer, Recognizer, { |
|
|
this.manager.emit(this.options.event, this._input);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Rotate
|
|
|
* Recognized when two or more pointer are moving in a circular motion.
|
|
|
* @constructor
|
|
|
* @extends AttrRecognizer
|
|
|
*/
|
|
|
function RotateRecognizer() {
|
|
|
function RotateRecognizer() {
|
|
|
AttrRecognizer.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(RotateRecognizer, AttrRecognizer, {
|
|
|
inherit(RotateRecognizer, AttrRecognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof RotateRecognizer
|
...
|
...
|
@@ -2528,19 +2528,19 @@ inherit(RotateRecognizer, AttrRecognizer, { |
|
|
return this._super.attrTest.call(this, input) &&
|
|
|
(Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Swipe
|
|
|
* Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
|
|
|
* @constructor
|
|
|
* @extends AttrRecognizer
|
|
|
*/
|
|
|
function SwipeRecognizer() {
|
|
|
function SwipeRecognizer() {
|
|
|
AttrRecognizer.apply(this, arguments);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(SwipeRecognizer, AttrRecognizer, {
|
|
|
inherit(SwipeRecognizer, AttrRecognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof SwipeRecognizer
|
...
|
...
|
@@ -2584,9 +2584,9 @@ inherit(SwipeRecognizer, AttrRecognizer, { |
|
|
|
|
|
this.manager.emit(this.options.event, input);
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
|
|
|
* between the given interval and position. The delay option can be used to recognize multi-taps without firing
|
|
|
* a single tap.
|
...
|
...
|
@@ -2596,7 +2596,7 @@ inherit(SwipeRecognizer, AttrRecognizer, { |
|
|
* @constructor
|
|
|
* @extends Recognizer
|
|
|
*/
|
|
|
function TapRecognizer() {
|
|
|
function TapRecognizer() {
|
|
|
Recognizer.apply(this, arguments);
|
|
|
|
|
|
// previous time and center,
|
...
|
...
|
@@ -2607,9 +2607,9 @@ function TapRecognizer() { |
|
|
this._timer = null;
|
|
|
this._input = null;
|
|
|
this.count = 0;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
inherit(TapRecognizer, Recognizer, {
|
|
|
inherit(TapRecognizer, Recognizer, {
|
|
|
/**
|
|
|
* @namespace
|
|
|
* @memberof PinchRecognizer
|
...
|
...
|
@@ -2699,30 +2699,30 @@ inherit(TapRecognizer, Recognizer, { |
|
|
this.manager.emit(this.options.event, this._input);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Simple way to create a manager with a default set of recognizers.
|
|
|
* @param {HTMLElement} element
|
|
|
* @param {Object} [options]
|
|
|
* @constructor
|
|
|
*/
|
|
|
function Hammer(element, options) {
|
|
|
function Hammer(element, options) {
|
|
|
options = options || {};
|
|
|
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
|
|
|
return new Manager(element, options);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* @const {string}
|
|
|
*/
|
|
|
Hammer.VERSION = '2.0.8';
|
|
|
Hammer.VERSION = '2.0.8';
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* default settings
|
|
|
* @namespace
|
|
|
*/
|
|
|
Hammer.defaults = {
|
|
|
Hammer.defaults = {
|
|
|
/**
|
|
|
* set if DOM events are being triggered.
|
|
|
* But this is slower and unused by simple implementations, so disabled by default.
|
...
|
...
|
@@ -2828,18 +2828,18 @@ Hammer.defaults = { |
|
|
*/
|
|
|
tapHighlightColor: 'rgba(0,0,0,0)'
|
|
|
}
|
|
|
};
|
|
|
};
|
|
|
|
|
|
var STOP = 1;
|
|
|
var FORCED_STOP = 2;
|
|
|
var STOP = 1;
|
|
|
var FORCED_STOP = 2;
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Manager
|
|
|
* @param {HTMLElement} element
|
|
|
* @param {Object} [options]
|
|
|
* @constructor
|
|
|
*/
|
|
|
function Manager(element, options) {
|
|
|
function Manager(element, options) {
|
|
|
this.options = assign({}, Hammer.defaults, options || {});
|
|
|
|
|
|
this.options.inputTarget = this.options.inputTarget || element;
|
...
|
...
|
@@ -2860,9 +2860,9 @@ function Manager(element, options) { |
|
|
item[2] && recognizer.recognizeWith(item[2]);
|
|
|
item[3] && recognizer.requireFailure(item[3]);
|
|
|
}, this);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Manager.prototype = {
|
|
|
Manager.prototype = {
|
|
|
/**
|
|
|
* set options
|
|
|
* @param {Object} options
|
...
|
...
|
@@ -3104,14 +3104,14 @@ Manager.prototype = { |
|
|
this.input.destroy();
|
|
|
this.element = null;
|
|
|
}
|
|
|
};
|
|
|
};
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* add/remove the css properties as defined in manager.options.cssProps
|
|
|
* @param {Manager} manager
|
|
|
* @param {Boolean} add
|
|
|
*/
|
|
|
function toggleCssProps(manager, add) {
|
|
|
function toggleCssProps(manager, add) {
|
|
|
var element = manager.element;
|
|
|
if (!element.style) {
|
|
|
return;
|
...
|
...
|
@@ -3129,21 +3129,21 @@ function toggleCssProps(manager, add) { |
|
|
if (!add) {
|
|
|
manager.oldCssProps = {};
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* trigger dom event
|
|
|
* @param {String} event
|
|
|
* @param {Object} data
|
|
|
*/
|
|
|
function triggerDomEvent(event, data) {
|
|
|
function triggerDomEvent(event, data) {
|
|
|
var gestureEvent = document.createEvent('Event');
|
|
|
gestureEvent.initEvent(event, true, true);
|
|
|
gestureEvent.gesture = data;
|
|
|
data.target.dispatchEvent(gestureEvent);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
assign(Hammer, {
|
|
|
assign(Hammer, {
|
|
|
INPUT_START: INPUT_START,
|
|
|
INPUT_MOVE: INPUT_MOVE,
|
|
|
INPUT_END: INPUT_END,
|
...
|
...
|
@@ -3194,22 +3194,22 @@ assign(Hammer, { |
|
|
inherit: inherit,
|
|
|
bindFn: bindFn,
|
|
|
prefixed: prefixed
|
|
|
});
|
|
|
});
|
|
|
|
|
|
// this prevents errors when Hammer is loaded in the presence of an AMD
|
|
|
// style loader but by script tag, not by the loader.
|
|
|
var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {})); // jshint ignore:line
|
|
|
freeGlobal.Hammer = Hammer;
|
|
|
var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {})); // jshint ignore:line
|
|
|
freeGlobal.Hammer = Hammer;
|
|
|
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
if (typeof define === 'function' && define.amd) {
|
|
|
define(function() {
|
|
|
return Hammer;
|
|
|
});
|
|
|
} else if (typeof module != 'undefined' && module.exports) {
|
|
|
} else if (typeof module != 'undefined' && module.exports) {
|
|
|
module.exports = Hammer;
|
|
|
} else {
|
|
|
} else {
|
|
|
window[exportName] = Hammer;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
})(window, document, 'Hammer');
|
|
|
|
...
|
...
|
@@ -3640,8 +3640,8 @@ if (typeof define === 'function' && define.amd) { |
|
|
}($);
|
|
|
|
|
|
/* ===============================================================================
|
|
|
************ Pull to refreh ************
|
|
|
=============================================================================== */
|
|
|
************ Pull to refreh ************
|
|
|
=============================================================================== */
|
|
|
/* global $:true */
|
|
|
|
|
|
+function ($) {
|
...
|
...
|
@@ -3761,8 +3761,8 @@ if (typeof define === 'function' && define.amd) { |
|
|
}($);
|
|
|
|
|
|
/* ===============================================================================
|
|
|
************ Infinite ************
|
|
|
=============================================================================== */
|
|
|
************ Infinite ************
|
|
|
=============================================================================== */
|
|
|
/* global $:true */
|
|
|
+function ($) {
|
|
|
"use strict";
|
...
|
...
|
@@ -3889,8 +3889,8 @@ if (typeof define === 'function' && define.amd) { |
|
|
}($);
|
|
|
|
|
|
/*===========================
|
|
|
Device/OS Detection
|
|
|
===========================*/
|
|
|
Device/OS Detection
|
|
|
===========================*/
|
|
|
/* global $:true */
|
|
|
;(function ($) {
|
|
|
"use strict";
|
...
|
...
|
@@ -3994,8 +3994,8 @@ Device/OS Detection |
|
|
})($);
|
|
|
|
|
|
/*======================================================
|
|
|
************ Picker ************
|
|
|
======================================================*/
|
|
|
************ Picker ************
|
|
|
======================================================*/
|
|
|
/* global $:true */
|
|
|
/* jshint unused:false */
|
|
|
/* jshint multistr:true */
|
...
|
...
|
@@ -4962,8 +4962,8 @@ Device/OS Detection |
|
|
}($);
|
|
|
|
|
|
/*======================================================
|
|
|
************ Calendar ************
|
|
|
======================================================*/
|
|
|
************ Calendar ************
|
|
|
======================================================*/
|
|
|
/* global $:true */
|
|
|
/*jshint unused: false*/
|
|
|
+function ($) {
|
...
|
...
|
@@ -5886,12 +5886,22 @@ Device/OS Detection |
|
|
$(this.input).picker(p);
|
|
|
}
|
|
|
|
|
|
var date=new Date();
|
|
|
var dat=date.getDate();
|
|
|
console.log(dat);
|
|
|
if(dat<10){
|
|
|
dat='0'+dat;
|
|
|
}else{
|
|
|
dat=dat
|
|
|
}
|
|
|
Datetime.prototype = {
|
|
|
getDays : function(max) {
|
|
|
var days = [];
|
|
|
for(var i=1; i<= (max||31);i++) {
|
|
|
days.push(i < 10 ? "0"+i : i);
|
|
|
}
|
|
|
|
|
|
//for(var i=1; i<= (max||31);i++) {
|
|
|
// days.push(i < 10 ? "0"+i : i);
|
|
|
//}
|
|
|
days.push(dat);
|
|
|
return days;
|
|
|
},
|
|
|
|
...
|
...
|
@@ -5967,7 +5977,16 @@ Device/OS Detection |
|
|
{
|
|
|
values: (function () {
|
|
|
var dates = [];
|
|
|
for (var i=1; i<=31; i++) dates.push(formatNumber(i));
|
|
|
var date=new Date();
|
|
|
var dat=date.getDate();
|
|
|
console.log(dat);
|
|
|
if(dat<10){
|
|
|
dat='0'+dat;
|
|
|
}else{
|
|
|
dat=dat
|
|
|
}
|
|
|
//for (var i=1; i<=31; i++)
|
|
|
dates.push(dat);
|
|
|
return dates;
|
|
|
})()
|
|
|
},
|
...
|
...
|
@@ -6014,11 +6033,17 @@ Device/OS Detection |
|
|
});
|
|
|
};
|
|
|
|
|
|
//自定义月
|
|
|
var date=new Date();
|
|
|
var month=date.getMonth()+1;
|
|
|
if(month<10){
|
|
|
month='0'+month
|
|
|
}else{
|
|
|
month=month;
|
|
|
}
|
|
|
|
|
|
|
|
|
defaults = $.fn.datetimePicker.prototype.defaults = {
|
|
|
|
|
|
|
|
|
input: undefined, // 默认值
|
|
|
min: undefined, // YYYY-MM-DD 最大最小值只比较年月日,不比较时分秒
|
|
|
max: undefined, // YYYY-MM-DD
|
...
|
...
|
@@ -6026,7 +6051,7 @@ Device/OS Detection |
|
|
monthSplit: '-',
|
|
|
dateSplit: '', // 默认为空
|
|
|
datetimeSplit: ' ', // 日期和时间之间的分隔符,不可为空
|
|
|
monthes: ('01 02 03 04 05 06 07 08 09 10 11 12').split(' '),
|
|
|
monthes: (month).split(' '),
|
|
|
// monthes:month.split(' '),
|
|
|
years: (function () {
|
|
|
var arr = [];
|
...
|
...
|
@@ -6078,8 +6103,8 @@ Device/OS Detection |
|
|
}($);
|
|
|
|
|
|
/*======================================================
|
|
|
************ Picker ************
|
|
|
======================================================*/
|
|
|
************ Picker ************
|
|
|
======================================================*/
|
|
|
/* global $:true */
|
|
|
|
|
|
+ function($) {
|
...
|
...
|
@@ -6135,8 +6160,8 @@ Device/OS Detection |
|
|
}($);
|
|
|
|
|
|
/* ===============================================================================
|
|
|
************ Notification ************
|
|
|
=============================================================================== */
|
|
|
************ Notification ************
|
|
|
=============================================================================== */
|
|
|
/* global $:true */
|
|
|
+function ($) {
|
|
|
"use strict";
|
...
|
...
|
@@ -6348,8 +6373,8 @@ Device/OS Detection |
|
|
}($);
|
|
|
|
|
|
/* ===============================================================================
|
|
|
************ Swipeout ************
|
|
|
=============================================================================== */
|
|
|
************ Swipeout ************
|
|
|
=============================================================================== */
|
|
|
/* global $:true */
|
|
|
|
|
|
+function ($) {
|
...
|
...
|
|