-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 Ordering for touch and mouse events #7378
Conversation
@davepagurek @limzykenneth I've tried to maintain the original behavior that these issues aim to address. We also discussed the deprecation of |
If there are no special differences between |
I've removed them from |
02ebb48
to
0b078e9
Compare
It probably can mention supporting touch as well although there may not be practical differences. |
0b078e9
to
3d833d1
Compare
3d833d1
to
b6c0967
Compare
src/core/main.js
Outdated
mousemove: null, | ||
mousedown: null, | ||
mouseup: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these and the touch ones below still need to be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes! I missed these during the cleanup. But I think we need the touch ones for the touches[]
array since we're handling multiple touches with touch events. I've removed the mouse events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be possible to implement touches[]
with pointer events as well, essentially caching the events as they come in, perhaps something like described here: https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events/Multi-touch_interaction
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the local test sketches you tried are working as intended then it should be fine for now, you can try to fix the tests if it is easy to do but that's not a priority as I may need to rewrite them later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized later that if I implement touches with pointer-events then onpointerup()/down()/move()
exists in both mouse.js and touch.js and mousePressed()/Released()
stops working. I think this is because, for sketches, these events fire from both touch.js
and mouse.js
in parallel. So, maybe the choice lies between having one file pointer.js
/ one file which would have pointer events for touches and mouse or letting the touches be decoupled by using touch events.
I did try a pointer.js
handling touches and mouse on the basis of event.pointerType
and everything seems to work. Let me know if I should go with this approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's go with just one file pointer.js
For the test we'll probably transition to use Vitest Browser Mode Interaction API but I can handle that after this is completed. |
2f18a47
to
6f36037
Compare
73d0cc6
to
dcaa55a
Compare
I've uploaded the build of p5.js for this PR and tested these sketches here: |
7a62bfd
to
a9526be
Compare
This is looking good @diyaayay! @limzykenneth is there anything else we want to add to this PR before merging? There are some follow-up updates to |
Just to confirm the tested existing sketches work as before without breaking changes? If so then let's go ahead and merge. |
Oh looks like this mouseDragged one is triggering the drag event on mouse move: https://editor.p5js.org/diya.solanki.31/sketches/aYfJEzpjgu Other than that they look good from my testing! |
My bad! I think it should work as intended now. I've updated the sketch too to test it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I'll merge this, and then we can change the base of your other PR.
Resolves #7260 and #7195
Changes:
Description:
I have tested all the examples given for both the issues above on an Android device, and Windows. The outputs are same for both the touch device, and mouse.
Screenshots of the change:
PR Checklist
npm run lint
passes