|
|
@ -7,23 +7,14 @@ var Hammer = require('./module/hammer'); |
|
|
|
*/ |
|
|
|
exports.onTouch = function (hammer, callback) { |
|
|
|
callback.inputHandler = function (event) { |
|
|
|
if (event.isFirst && !isTouching) { |
|
|
|
if (event.isFirst) { |
|
|
|
callback(event); |
|
|
|
|
|
|
|
isTouching = true; |
|
|
|
setTimeout(function () { |
|
|
|
isTouching = false; |
|
|
|
}, 0); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
hammer.on('hammer.input', callback.inputHandler); |
|
|
|
}; |
|
|
|
|
|
|
|
// isTouching is true while a touch action is being emitted
|
|
|
|
// this is a hack to prevent `touch` from being fired twice
|
|
|
|
var isTouching = false; |
|
|
|
|
|
|
|
/** |
|
|
|
* Register a release event, taking place after a gesture |
|
|
|
* @param {Hammer} hammer A hammer instance |
|
|
@ -31,13 +22,8 @@ var isTouching = false; |
|
|
|
*/ |
|
|
|
exports.onRelease = function (hammer, callback) { |
|
|
|
callback.inputHandler = function (event) { |
|
|
|
if (event.isFinal && !isReleasing) { |
|
|
|
if (event.isFinal) { |
|
|
|
callback(event); |
|
|
|
|
|
|
|
isReleasing = true; |
|
|
|
setTimeout(function () { |
|
|
|
isReleasing = false; |
|
|
|
}, 0); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
@ -45,11 +31,6 @@ exports.onRelease = function (hammer, callback) { |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
// isReleasing is true while a release action is being emitted
|
|
|
|
// this is a hack to prevent `release` from being fired twice
|
|
|
|
var isReleasing = false; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* Unregister a touch event, taking place before a gesture |
|
|
|
* @param {Hammer} hammer A hammer instance |
|
|
|