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

mousePressed() and touchStarted() run twice for each tap on Chrome on Android #6030

Closed
1 of 17 tasks
greenStone83 opened this issue Feb 23, 2023 · 8 comments
Closed
1 of 17 tasks

Comments

@greenStone83
Copy link

greenStone83 commented Feb 23, 2023

Most appropriate sub-area of p5.js?

  • Accessibility
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Build Process
  • Unit Testing
  • Internalization
  • Friendly Errors
  • Other (specify if possible)

p5.js version

1.5.0

Web browser and version

Chrome - Most Recent

Operating System

Android - Most Recent

Steps to reproduce this

When I go to this link on Chrome on my Android and tap the screen the number goes up by two when it should go up by 1. This happens with touchStarted() too. Firefox works fine.

https://editor.p5js.org/greenStone83/full/qUpWvNmjk

@greenStone83 greenStone83 changed the title mouseClicked() and touchStarted() run twice for each tap on Chrome on Android mousePressed() and touchStarted() run twice for each tap on Chrome on Android Feb 23, 2023
@shamun-khatri
Copy link

I want to work on this issue.
By the way I have fixed the issue on my local system, Its not problem in function its issue of default browser behaviour that we can fix by adding "return false".

What i have fixed is Example section on https://p5js.org/reference/#/p5/mousePressed the same issue arise there while using on chrome on android.

Its my firs time open source contribution so should i generate pull request for this to commit whatever change i made?

@limzykenneth
Copy link
Member

@shamun-khatri Do you mean you have a fix for just the mousePressed reference example with adding return false to it and not the general fix for the double event firing?

I don't think the double event firing can be fixed on p5.js side because if we default to stopping propogation of mousePressed to touchStarted and vice versa, we will likely break sketches that expected the behaviour to be passed through to other elements and events. Using return false manually in your own sketches when you know that you don't need that behaviour is probably a safer choice.

@shamun-khatri
Copy link

@limzykenneth Yes you are right, BTW can i know where is actually mousePressed method is defined i am trying to find but cant find which is actual method, But i have fixed that example having same problem on chrome on android so should i generate pull request for that.

And i am new to open source contribution so may be some question seems silly for you but i am trying to applying by learning.

@limzykenneth
Copy link
Member

You can find the exact source at the bottom of the reference page for mousePressed() (pretty handy feature!)

@nikhil061102
Copy link

@limzykenneth Hello Sir, can I work on this issue or has it already been assigned to someone or resolved already. If not I would like to to give it a try. This will also be a good practice for me for GSoC 2023.
Thank You :)

@limzykenneth
Copy link
Member

@nikhil061102 It would be helpful if you are interested in resolving an issue to try and replicate the reported problem then identify potential solution to it and report it back here so we can see what solutions would work here.

@RandomGamingDev
Copy link
Contributor

#6740 fixes this

@davepagurek
Copy link
Contributor

Thanks @RandomGamingDev! I'm going to close this, but anyone, feel free to comment if you discover a case we missed!

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

No branches or pull requests

6 participants