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

fix: support touchStarted, touchEnded, touchMoved #24

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

Conversation

psugihara
Copy link

@psugihara psugihara commented Mar 12, 2024

fixes #22

Hey @LingDong- thanks for this awesome lib. Needed to get touch working for mobile and thought I'd share my solution back.

You use this by setting the handlers on q5:

const q5 = new Q5();
q5.touchStarted = () => {}
q5.touchMoved = () => {}
q5.touchEnded = () => {}

@GoToLoop
Copy link

$.touches = [...event.touches].map(getTouchInfo);

Isn't property touches an array already?!

@psugihara
Copy link
Author

I think it's a TouchList which doesn't have .map in all implementations.

https://developer.mozilla.org/en-US/docs/Web/API/TouchList

@GoToLoop
Copy link

GoToLoop commented Mar 13, 2024

Oh, now I've got it why: $.touches = [...event.touches].map(getTouchInfo);

BtW, the old way to do that is:
$.touches = Array.prototype.map.call(event.touches, getTouchInfo);

@psugihara
Copy link
Author

Cool. That seems nice bc it doesn't create a new array.

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.

touches array doesn't work, fixed in quinton-ashley/q5.js
2 participants