g6-hammerjs
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -33,3 +33,2 @@ "use strict"; | ||
* Simple way to create a manager with a default set of recognizers. | ||
* @param {HTMLElement} element | ||
* @param {Object} [options] | ||
@@ -39,6 +38,6 @@ * @constructor | ||
class Hammer { | ||
constructor(element, options) { | ||
constructor(options) { | ||
options = options || {}; | ||
options.recognizers = (0, _ifUndefined.default)(options.recognizers, Hammer.defaults.preset); | ||
return new _manager.default(element, options); | ||
return new _manager.default(options); | ||
} | ||
@@ -49,3 +48,4 @@ | ||
* @private | ||
* @const {string} | ||
* default settings | ||
* @namespace | ||
*/ | ||
@@ -55,9 +55,2 @@ | ||
exports.default = Hammer; | ||
Hammer.VERSION = '{{PKG_VERSION}}'; | ||
/** | ||
* @private | ||
* default settings | ||
* @namespace | ||
*/ | ||
Hammer.defaults = { | ||
@@ -91,12 +84,2 @@ /** | ||
* @private | ||
* EXPERIMENTAL FEATURE -- can be removed/changed | ||
* Change the parent input target element. | ||
* If Null, then it is being set the to main element. | ||
* @type {Null|EventTarget} | ||
* @default null | ||
*/ | ||
inputTarget: null, | ||
/** | ||
* @private | ||
* force an input class | ||
@@ -126,62 +109,3 @@ * @type {Null|Function} | ||
taps: 2 | ||
}, ['tap']], [_press.default]], | ||
/** | ||
* @private | ||
* Some CSS properties can be used to improve the working of Hammer. | ||
* Add them to this method and they will be set when creating a new Manager. | ||
* @namespace | ||
*/ | ||
cssProps: { | ||
/** | ||
* @private | ||
* Disables text selection to improve the dragging gesture. Mainly for desktop browsers. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
userSelect: 'none', | ||
/** | ||
* @private | ||
* Disable the Windows Phone grippers when pressing an element. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
touchSelect: 'none', | ||
/** | ||
* @private | ||
* Disables the default callout shown when you touch and hold a touch target. | ||
* On iOS, when you touch and hold a touch target such as a link, Safari displays | ||
* a callout containing information about the link. This property allows you to disable that callout. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
touchCallout: 'none', | ||
/** | ||
* @private | ||
* Specifies whether zooming is enabled. Used by IE10> | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
contentZooming: 'none', | ||
/** | ||
* @private | ||
* Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
userDrag: 'none', | ||
/** | ||
* @private | ||
* Overrides the highlight color shown when the user taps a link or a JavaScript | ||
* clickable element in iOS. This property obeys the alpha value, if specified. | ||
* @type {String} | ||
* @default 'rgba(0,0,0,0)' | ||
*/ | ||
tapHighlightColor: 'rgba(0,0,0,0)' | ||
} | ||
}, ['tap']], [_press.default]] | ||
}; |
@@ -81,11 +81,3 @@ "use strict"; | ||
input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers; | ||
(0, _computeIntervalInputData.default)(session, input); // find the correct target | ||
let target = manager.element; | ||
if ((0, _hasParent.default)(input.srcEvent.target, target)) { | ||
target = input.srcEvent.target; | ||
} | ||
input.target = target; | ||
(0, _computeIntervalInputData.default)(session, input); | ||
} |
@@ -26,8 +26,6 @@ "use strict"; | ||
this.manager = manager; | ||
this.callback = callback; | ||
this.element = manager.element; | ||
this.target = manager.options.inputTarget; // smaller wrapper around the handler, for the scope and the enabled state of the manager, | ||
this.callback = callback; // smaller wrapper around the handler, for the scope and the enabled state of the manager, | ||
// so when disabled the input events are completely bypassed. | ||
this.domHandler = function (ev) { | ||
this.eventHandler = function (ev) { | ||
if ((0, _boolOrFn.default)(manager.options.enable, [manager])) { | ||
@@ -54,3 +52,3 @@ self.handler(ev); | ||
init() { | ||
(0, _addEventListeners.addManagerListeners)(this.manager, this.events || '', this.domHandler); | ||
(0, _addEventListeners.addManagerListeners)(this.manager, this.events || '', this.eventHandler); | ||
} | ||
@@ -63,3 +61,3 @@ /** | ||
destroy() { | ||
removeManagerListeners(this.manager, this.events || '', this.domHandler); | ||
removeManagerListeners(this.manager, this.events || '', this.eventHandler); | ||
} | ||
@@ -66,0 +64,0 @@ |
@@ -35,3 +35,2 @@ "use strict"; | ||
* Manager | ||
* @param {HTMLElement} element | ||
* @param {Object} [options] | ||
@@ -42,5 +41,4 @@ * @constructor | ||
class Manager { | ||
constructor(element, options) { | ||
constructor(options) { | ||
this.options = (0, _assign.default)({}, _hammer.default.defaults, options || {}); | ||
this.options.inputTarget = this.options.inputTarget || element; | ||
this.handlers = {}; | ||
@@ -50,4 +48,2 @@ this.filters = []; | ||
this.recognizers = []; | ||
this.oldCssProps = {}; | ||
this.element = element || {}; | ||
this.input = (0, _createInputInstance.default)(this); | ||
@@ -76,9 +72,2 @@ this.touchAction = new _touchactionConstructor.default(this, this.options.touchAction); | ||
if (options.inputTarget) { | ||
// Clean up existing event listeners and reinitialize | ||
this.input.destroy(); | ||
this.input.target = options.inputTarget; | ||
this.input.init(); | ||
} | ||
return this; | ||
@@ -362,3 +351,2 @@ } | ||
this.input.destroy(); | ||
this.element = null; | ||
} | ||
@@ -365,0 +353,0 @@ |
@@ -8,9 +8,3 @@ "use strict"; | ||
var _touchactionConsts = require("./touchaction-Consts"); | ||
function getTouchActionProps() { | ||
if (!_touchactionConsts.NATIVE_TOUCH_ACTION) { | ||
return false; | ||
} | ||
let touchMap = {}; | ||
@@ -17,0 +11,0 @@ ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(val => { |
@@ -48,6 +48,2 @@ "use strict"; | ||
if (_touchactionConsts.NATIVE_TOUCH_ACTION && this.manager.element.style && _touchactionConsts.TOUCH_ACTION_MAP[value]) { | ||
this.manager.element.style[_touchactionConsts.PREFIXED_TOUCH_ACTION] = value; | ||
} | ||
this.actions = value.toLowerCase().trim(); | ||
@@ -54,0 +50,0 @@ } |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.TOUCH_ACTION_MAP = exports.TOUCH_ACTION_PAN_Y = exports.TOUCH_ACTION_PAN_X = exports.TOUCH_ACTION_NONE = exports.TOUCH_ACTION_MANIPULATION = exports.TOUCH_ACTION_COMPUTE = exports.TOUCH_ACTION_AUTO = exports.NATIVE_TOUCH_ACTION = exports.PREFIXED_TOUCH_ACTION = void 0; | ||
exports.TOUCH_ACTION_MAP = exports.TOUCH_ACTION_PAN_Y = exports.TOUCH_ACTION_PAN_X = exports.TOUCH_ACTION_NONE = exports.TOUCH_ACTION_MANIPULATION = exports.TOUCH_ACTION_COMPUTE = exports.TOUCH_ACTION_AUTO = void 0; | ||
@@ -15,7 +15,3 @@ var _utilsConsts = require("../utils/utils-consts"); | ||
const PREFIXED_TOUCH_ACTION = 'touchAction'; | ||
exports.PREFIXED_TOUCH_ACTION = PREFIXED_TOUCH_ACTION; | ||
const NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined; // magical touchAction value | ||
exports.NATIVE_TOUCH_ACTION = NATIVE_TOUCH_ACTION; | ||
// magical touchAction value | ||
const TOUCH_ACTION_COMPUTE = 'compute'; | ||
@@ -22,0 +18,0 @@ exports.TOUCH_ACTION_COMPUTE = TOUCH_ACTION_COMPUTE; |
@@ -5,11 +5,7 @@ { | ||
"description": "A javascript library for multi-touch gestures", | ||
"version": "0.0.3", | ||
"homepage": "http://hammerjs.github.io/", | ||
"version": "0.0.4", | ||
"main": "lib/index.js", | ||
"unpkg": "dist/hammer.min.js", | ||
"license": "MIT", | ||
"keywords": [ | ||
"touch", | ||
"gestures" | ||
], | ||
"keywords": ["touch", "gestures"], | ||
"author": { | ||
@@ -31,6 +27,6 @@ "name": "Jorik Tangelder", | ||
"type": "git", | ||
"url": "git://github.com/hammerjs/hammer.js.git" | ||
"url": "https://github.com/antvis/g6" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/hammerjs/hammer.js/issues" | ||
"url": "https://github.com/antvis/g6/issues" | ||
}, | ||
@@ -37,0 +33,0 @@ "dependencies": {}, |
@@ -15,3 +15,2 @@ import ifUndefined from './utils/if-undefined'; | ||
* Simple way to create a manager with a default set of recognizers. | ||
* @param {HTMLElement} element | ||
* @param {Object} [options] | ||
@@ -21,9 +20,6 @@ * @constructor | ||
export default class Hammer { | ||
constructor(element, options) { | ||
constructor(options) { | ||
options = options || {}; | ||
options.recognizers = ifUndefined( | ||
options.recognizers, | ||
Hammer.defaults.preset, | ||
); | ||
return new Manager(element, options); | ||
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset); | ||
return new Manager(options); | ||
} | ||
@@ -34,8 +30,2 @@ } | ||
* @private | ||
* @const {string} | ||
*/ | ||
Hammer.VERSION = '{{PKG_VERSION}}'; | ||
/** | ||
* @private | ||
* default settings | ||
@@ -72,12 +62,2 @@ * @namespace | ||
* @private | ||
* EXPERIMENTAL FEATURE -- can be removed/changed | ||
* Change the parent input target element. | ||
* If Null, then it is being set the to main element. | ||
* @type {Null|EventTarget} | ||
* @default null | ||
*/ | ||
inputTarget: null, | ||
/** | ||
* @private | ||
* force an input class | ||
@@ -105,61 +85,2 @@ * @type {Null|Function} | ||
], | ||
/** | ||
* @private | ||
* Some CSS properties can be used to improve the working of Hammer. | ||
* Add them to this method and they will be set when creating a new Manager. | ||
* @namespace | ||
*/ | ||
cssProps: { | ||
/** | ||
* @private | ||
* Disables text selection to improve the dragging gesture. Mainly for desktop browsers. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
userSelect: 'none', | ||
/** | ||
* @private | ||
* Disable the Windows Phone grippers when pressing an element. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
touchSelect: 'none', | ||
/** | ||
* @private | ||
* Disables the default callout shown when you touch and hold a touch target. | ||
* On iOS, when you touch and hold a touch target such as a link, Safari displays | ||
* a callout containing information about the link. This property allows you to disable that callout. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
touchCallout: 'none', | ||
/** | ||
* @private | ||
* Specifies whether zooming is enabled. Used by IE10> | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
contentZooming: 'none', | ||
/** | ||
* @private | ||
* Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers. | ||
* @type {String} | ||
* @default 'none' | ||
*/ | ||
userDrag: 'none', | ||
/** | ||
* @private | ||
* Overrides the highlight color shown when the user taps a link or a JavaScript | ||
* clickable element in iOS. This property obeys the alpha value, if specified. | ||
* @type {String} | ||
* @default 'rgba(0,0,0,0)' | ||
*/ | ||
tapHighlightColor: 'rgba(0,0,0,0)', | ||
}, | ||
}; |
@@ -51,18 +51,10 @@ import { now } from '../utils/utils-consts'; | ||
let overallVelocity = getVelocity( | ||
input.deltaTime, | ||
input.deltaX, | ||
input.deltaY, | ||
); | ||
let overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY); | ||
input.overallVelocityX = overallVelocity.x; | ||
input.overallVelocityY = overallVelocity.y; | ||
input.overallVelocity = | ||
abs(overallVelocity.x) > abs(overallVelocity.y) | ||
? overallVelocity.x | ||
: overallVelocity.y; | ||
abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y; | ||
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1; | ||
input.rotation = firstMultiple | ||
? getRotation(firstMultiple.pointers, pointers) | ||
: 0; | ||
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0; | ||
@@ -76,9 +68,2 @@ input.maxPointers = !session.prevInput | ||
computeIntervalInputData(session, input); | ||
// find the correct target | ||
let target = manager.element; | ||
if (hasParent(input.srcEvent.target, target)) { | ||
target = input.srcEvent.target; | ||
} | ||
input.target = target; | ||
} |
@@ -17,8 +17,6 @@ import boolOrFn from '../utils/bool-or-fn'; | ||
this.callback = callback; | ||
this.element = manager.element; | ||
this.target = manager.options.inputTarget; | ||
// smaller wrapper around the handler, for the scope and the enabled state of the manager, | ||
// so when disabled the input events are completely bypassed. | ||
this.domHandler = function (ev) { | ||
this.eventHandler = function (ev) { | ||
if (boolOrFn(manager.options.enable, [manager])) { | ||
@@ -42,3 +40,3 @@ self.handler(ev); | ||
init() { | ||
addManagerListeners(this.manager, this.events || '', this.domHandler); | ||
addManagerListeners(this.manager, this.events || '', this.eventHandler); | ||
} | ||
@@ -50,4 +48,4 @@ | ||
destroy() { | ||
removeManagerListeners(this.manager, this.events || '', this.domHandler); | ||
removeManagerListeners(this.manager, this.events || '', this.eventHandler); | ||
} | ||
} |
@@ -23,3 +23,2 @@ import assign from './utils/assign'; | ||
* Manager | ||
* @param {HTMLElement} element | ||
* @param {Object} [options] | ||
@@ -29,7 +28,5 @@ * @constructor | ||
export default class Manager { | ||
constructor(element, options) { | ||
constructor(options) { | ||
this.options = assign({}, Hammer.defaults, options || {}); | ||
this.options.inputTarget = this.options.inputTarget || element; | ||
this.handlers = {}; | ||
@@ -39,5 +36,3 @@ this.filters = []; | ||
this.recognizers = []; | ||
this.oldCssProps = {}; | ||
this.element = element || {}; | ||
this.input = createInputInstance(this); | ||
@@ -70,8 +65,3 @@ this.touchAction = new TouchAction(this, this.options.touchAction); | ||
} | ||
if (options.inputTarget) { | ||
// Clean up existing event listeners and reinitialize | ||
this.input.destroy(); | ||
this.input.target = options.inputTarget; | ||
this.input.init(); | ||
} | ||
return this; | ||
@@ -128,6 +118,3 @@ } | ||
// or when we're in a new session | ||
if ( | ||
!curRecognizer || | ||
(curRecognizer && curRecognizer.state & STATE_RECOGNIZED) | ||
) { | ||
if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) { | ||
curRecognizer = session.curRecognizer = null; | ||
@@ -160,6 +147,3 @@ } | ||
// current active recognizer. but only if we don't already have an active recognizer | ||
if ( | ||
!curRecognizer && | ||
recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED) | ||
) { | ||
if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) { | ||
curRecognizer = session.curRecognizer = recognizer; | ||
@@ -281,4 +265,3 @@ } | ||
} else { | ||
handlers[event] && | ||
handlers[event].splice(inArray(handlers[event], handler), 1); | ||
handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1); | ||
} | ||
@@ -338,4 +321,3 @@ }); | ||
this.input.destroy(); | ||
this.element = null; | ||
} | ||
} |
@@ -1,7 +0,2 @@ | ||
import { NATIVE_TOUCH_ACTION } from './touchaction-Consts'; | ||
export default function getTouchActionProps() { | ||
if (!NATIVE_TOUCH_ACTION) { | ||
return false; | ||
} | ||
let touchMap = {}; | ||
@@ -8,0 +3,0 @@ ['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach( |
import { | ||
TOUCH_ACTION_COMPUTE, | ||
TOUCH_ACTION_MAP, | ||
NATIVE_TOUCH_ACTION, | ||
PREFIXED_TOUCH_ACTION, | ||
TOUCH_ACTION_NONE, | ||
@@ -44,9 +42,2 @@ TOUCH_ACTION_PAN_X, | ||
if ( | ||
NATIVE_TOUCH_ACTION && | ||
this.manager.element.style && | ||
TOUCH_ACTION_MAP[value] | ||
) { | ||
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value; | ||
} | ||
this.actions = value.toLowerCase().trim(); | ||
@@ -53,0 +44,0 @@ } |
import { TEST_ELEMENT } from '../utils/utils-consts'; | ||
import getTouchActionProps from './get-touchaction-props'; | ||
const PREFIXED_TOUCH_ACTION = 'touchAction'; | ||
const NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined; | ||
// magical touchAction value | ||
@@ -17,4 +14,2 @@ const TOUCH_ACTION_COMPUTE = 'compute'; | ||
export { | ||
PREFIXED_TOUCH_ACTION, | ||
NATIVE_TOUCH_ACTION, | ||
TOUCH_ACTION_AUTO, | ||
@@ -21,0 +16,0 @@ TOUCH_ACTION_COMPUTE, |
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
253315
6806
3