Skip to content

Conversation

@reijovosu
Copy link
Contributor

As describe on issue #1811 & #1815

Preventing google chrome mobile for firing duplicated mousePressed event when taping on element.

As describe on issue processing#1811 & processing#1815

Preventing google chrome mobile for firing duplicated mousePressed event when taping on element.
@lmccart lmccart merged commit 12a554f into processing:master Mar 14, 2017
@lmccart
Copy link
Member

lmccart commented Mar 14, 2017

looks good

if(executeDefault === false) {
e.preventDefault();
}
} else {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change causes problems with iOS (Safari). Specifically, once a sketch is created, it and the entire HTML page it is contained in will be unresponsive to actions that rely on ontouchend, such as link-clicking and button pushes. Commenting out the above else-branch makes everything work again.

I recommend that the above code is made conditional for the environment where it is needed (Chrome Mobile 56).

Meanwhile, I'm monkeypatching around the above 'fix'.

@tigoe
Copy link

tigoe commented Apr 4, 2017

Thanks, I'll give it a try and report back.

@lmccart
Copy link
Member

lmccart commented Apr 7, 2017

Ok, I updated the behavior of p5.js to only add duplicate firings if they are not already supported by the browser. Currently, chrome already fires off both mouse and touch events for a touch, firefox and safari do not. It is in the spec though, so we can expect that all browsers will eventually support this and the check for (window.PointerEvent) will be unnecessary. Here's more reading:
http://caniuse.com/#search=pointer%20events
https://www.w3.org/TR/pointerevents/
https://developer.mozilla.org/en-US/docs/Web/API/Touch_events/Supporting_both_TouchEvent_and_MouseEvent

The p5.js behavior has shifted slightly due to this. If you define a mouse related event (ie mousePressed, mouseMoved, etc), it will be triggered by either a mouse or a touch. It will trigger only once.

However, if you define a touch related event (ie touchStarted, touchEnded, etc), it will be triggered by a touch, but not by a mouse click. In the past mouse and touch functions were completely interchangeable, now they go one direction. So if you are trying to define a function that will trigger on either mouse or touch, use the mouse named one. If you want to define a function that only triggers on touch, use the touch related ones.

This preserves the functionality of select/option and any other elements that depend on the 'click' event.

@reijovosu reijovosu deleted the patch-1 branch April 8, 2017 18:42
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.

4 participants