Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/tap recognizer #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Feat/tap recognizer #3

wants to merge 3 commits into from

Conversation

danzaner
Copy link

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'.

@andrewdeandrade
Copy link

@danzaner To give you access to that repo, we're going to need to send you a private beta agreement since it's not a repo we're going to be making public. Can you send me an email at [email protected] and I'll send you a docusign agreement.

dmvaldman pushed a commit that referenced this pull request May 17, 2014
Update Travis with explicit emails
@kof
Copy link

kof commented Jun 28, 2014

However I recognize that using internal events is much better approach than what FastClick does, there should be a way to bind tap events easier than that. Probably Surface#on should be able to do this on fly or whatever so that we could just write at the end:

var surface = new Surface()
surface.on('tap', function() {})

@MylesBorins
Copy link

hey @danzaner can you move this to famous/famous referencing this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants