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

Register touchcancel and pointercancel events #74

Merged

Conversation

johnshaughnessy
Copy link
Contributor

We noticed our joysticks got stuck on screen if a touchcancel or pointercancel event was raised. This PR adds event listeners for those events, and then calls the same code as the touchend/pointerend event handler.

@yoannmoinet
Copy link
Owner

that's a really nice find.
I think it could fix multiple issues.
Thank you very much, I'll merge it and release a new version asap.

@yoannmoinet yoannmoinet merged commit 2c541a6 into yoannmoinet:master Jun 6, 2018
@yoannmoinet
Copy link
Owner

yoannmoinet commented Jun 6, 2018

Hi @johnshaughnessy

I had to push an update (52f9cb5) to your fix, I think you've lost yourself a bit on the usage of the handlers/event in ./start.js.
Also, I had an Error when, in the mouse or MSPointer context, we were trying to bind to the oncancel handler because it couldn't find their entry in the hashtable.

I agree (and apologise) that this isn't the clearest, easiest implementation possible... it was a long time ago, I was young and wild 😜
But it's working and, unfortunately, I don't have much time refactoring such a core mechanic.

For the explanation,
those are hashtables indexed by the handler name, eg end stands for the onend handler on the manager.
This magic logic happens here.

Since I had for the end handler's entry in the hashtable both touchend, touchcancel events, they were both handled by the onend handler thanks to this little help that splits the events to listen to.

Then the manager propagate those handlers down its collections via the onAny method.
Again, such an obvious implementation 😄

So for the touch, both touchend and touchcancel should have been handled correctly by the onend handler, and only pointercancel was actually missing in the hashtable for the pointer.

I'd love to know what was your issue with the touchcancel event, because it should have been working since the beginning, could you provide some reproduction steps where you have the issue of the event not being handled?

Because I feel like the issue could be coming from somewhere else.
(I've added the pointercancel event that was missing though)

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

Successfully merging this pull request may close these issues.

4 participants