Famous/inputs — pull request #3 by danzaner (2014-04-28 22:14:45+00:00)
Title: Feat/tap recognizer

This pull request obsoletes "topic-tap-doubletap-longpress (#2)". All functionality created in that branch is now encapsulated in TapRecognizer.js. TapRecognizer emits "tap", "doubletap" and "press" events. To use:
```
var tapRecognizer = new TapRecognizer({ emitEveryTap: "true" });
tapRecognizer.bindThis(this);
tapRecognizer.on('doubletap', _doubleTapHandler);
...
someSurface1.pipe(tapRecognizer);
someSurface2.pipe(tapRecognizer);

function _doubleTapHandler(event) {
console.log("_doubleTapHandler() event: " + JSON.stringify(event));
// optionally get the double-tapped origin (probably a Surface) from the tapRecognizer
var originSurface = tapRecognizer.getOriginByTouchIdentifier.call(tapRecognizer, event.touch);
// do something with/to originSurface
}
```

TapRecognizer.getOriginByTouchIdentifier(identifier) will get you the source object that piped the touch events into the TapRecognizer. TapRecognizer.getTouchEventByIdentifier(identifier) will get you the entire 'touch'. The .on() function demonstrated above is simply a convenience accessor to tapRecognizer.eventOutput.on(). Likewise, .bindThis() is just sugar for the eventOutput's .bindThis(). TapRecognizer registers with EventHandler, so standard .pipe to and .subscribe from calls are fine.

The only option is "emitEveryTap". 'true' emits every tap; 'false' suppresses the 'tap' event before a 'doubletap' event. Default is 'true'. Setting emitEveryTap to 'false' slows down tap processing as the TapRecognizer buffers the events until the correct determination can be made. If fast responses (<300ms) are needed, the event receiver will have to handle undesired 'tap' events preceding every 'doubletap'.