Skip to content

fix: support touchStarted, touchEnded, touchMoved#24

Closed
psugihara wants to merge 3 commits intoLingDong-:masterfrom
psugihara:22-touch-support
Closed

fix: support touchStarted, touchEnded, touchMoved#24
psugihara wants to merge 3 commits intoLingDong-:masterfrom
psugihara:22-touch-support

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.

@quinton-ashley
Copy link

@psugihara Try using q5.js v3!
https://q5js.org

@psugihara psugihara closed this May 9, 2025
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

3 participants