vis.js is a dynamic, browser-based visualization library
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

67 lines
1.9 KiB

/**
* Register a touch event, taking place before a gesture
* @param {Hammer} hammer A hammer instance
* @param {function} callback Callback, called as callback(event)
*/
exports.onTouch = function (hammer, callback) {
callback.inputHandler = function (event) {
if (event.isFirst) {
callback(event);
}
};
hammer.on('hammer.input', callback.inputHandler);
};
/**
* Register a release event, taking place after a gesture
* @param {Hammer} hammer A hammer instance
* @param {function} callback Callback, called as callback(event)
* @returns {*}
*/
exports.onRelease = function (hammer, callback) {
callback.inputHandler = function (event) {
if (event.isFinal) {
callback(event);
}
};
return hammer.on('hammer.input', callback.inputHandler);
};
/**
* Unregister a touch event, taking place before a gesture
* @param {Hammer} hammer A hammer instance
* @param {function} callback Callback, called as callback(event)
*/
exports.offTouch = function (hammer, callback) {
hammer.off('hammer.input', callback.inputHandler);
};
/**
* Unregister a release event, taking place before a gesture
* @param {Hammer} hammer A hammer instance
* @param {function} callback Callback, called as callback(event)
*/
exports.offRelease = exports.offTouch;
/**
* Hack the PinchRecognizer such that it doesn't prevent default behavior
* for vertical panning.
*
* Yeah ... this is quite a hack ... see https://github.com/hammerjs/hammer.js/issues/932
*
* @param {Hammer.Pinch} pinchRecognizer
* @return {Hammer.Pinch} returns the pinchRecognizer
*/
exports.disablePreventDefaultVertically = function (pinchRecognizer) {
var TOUCH_ACTION_PAN_Y = 'pan-y';
pinchRecognizer.getTouchAction = function() {
// default method returns [TOUCH_ACTION_NONE]
return [TOUCH_ACTION_PAN_Y];
};
return pinchRecognizer;
};