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

Event help #18

Open
chasegiunta opened this issue Jun 5, 2023 · 3 comments
Open

Event help #18

chasegiunta opened this issue Jun 5, 2023 · 3 comments

Comments

@chasegiunta
Copy link

Hi there! It's possible I'm being dense here, but I'm attempting to figure out how I can detect the start and end of a pinch gesture.

I was assuming that the phase property would let me know whether the callback is start or end, but in all cases, it's coming back as move.

Am I missing something? Thank you

const region = new wes.Region(el);
const pinch = new wes.Pinch(el, data => {
  console.log(data); // data.phase is always `move`
});
region.addGesture(pinch);
@mvanderkamp
Copy link
Owner

Yeah this is the way it currently behaves- the callback is only called when a gesture is "recognized". Which for Pinch only happens during the "move" phase. You could subclass Pinch and override the start/end methods.

I've been thinking about changing this to a more event/listener based approach where gestures emit start/move/stop/cancel events, perhaps as well as a "recognize" event. We'll see if I find the time...

@chasegiunta
Copy link
Author

@mvanderkamp Appreciate the clarification. Yes, it would definitely help! I'll see if I can hack something together. Thank you.

@mvanderkamp
Copy link
Owner

@chasegiunta I started taking a crack at this. My rough idea is to switch to an event emitting system and migrate to TypeScript for a v2.0.0 of the library. Since you're interested, I wonder if I could ask you some questions:

  1. Should all gestures emit events for all four phases?
  2. Should there be a separate "recognized" event?
    • The idea being that you could hook up to the phase events if you want precise control, or not worry about it and hook up to "recognize" if you don't want to have to worry about which phase(s) the gesture supports.
  3. What kind of data would it be important to see in a non-recognize event? My first draft is to include all the normal, non-gesture specific data (centroid, phase, etc). If there's something missing from this standard set of fields now might a good time to add it.
  4. I'm thinking just simple on(event_name, listener) / off(event_name, listener) methods for connecting / disconnecting listeners. Do you think anything more robust is warranted?

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

No branches or pull requests

2 participants