p5.js icon indicating copy to clipboard operation
p5.js copied to clipboard

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

Open greenStone83 opened this issue 2 years ago • 7 comments

Most appropriate sub-area of p5.js?

  • [ ] Accessibility
  • [ ] Color
  • [ ] Core/Environment/Rendering
  • [ ] Data
  • [ ] DOM
  • [X] 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 avatar Feb 23 '23 01:02 greenStone83

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?

shamun-khatri avatar Feb 25 '23 18:02 shamun-khatri

@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.

limzykenneth avatar Feb 27 '23 11:02 limzykenneth

@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.

shamun-khatri avatar Feb 27 '23 18:02 shamun-khatri

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

limzykenneth avatar Feb 28 '23 16:02 limzykenneth

@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 :)

nikhil061102 avatar Mar 25 '23 19:03 nikhil061102

@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.

limzykenneth avatar Apr 03 '23 13:04 limzykenneth

#6740 fixes this

RandomGamingDev avatar Jan 14 '24 19:01 RandomGamingDev

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

davepagurek avatar Mar 01 '24 01:03 davepagurek