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

Add a small tolerance when testing pointer event positions #6778

Merged
merged 1 commit into from May 11, 2017

Conversation

fredj
Copy link
Member

@fredj fredj commented May 8, 2017

@fredj
Copy link
Member Author

fredj commented May 8, 2017

@ischas can you test https://codepen.io/anon/pen/QvOPzp ?

@ischas
Copy link
Contributor

ischas commented May 8, 2017

@simonseyock ping

@simonseyock
Copy link
Member

I am sorry, i can't test this. The problem does not occur on my phone.

return pointerEvent.clientX != this.down_.clientX ||
pointerEvent.clientY != this.down_.clientY;
return Math.abs(pointerEvent.clientX - this.down_.clientX) > 1 ||
Math.abs(pointerEvent.clientY != this.down_.clientY) > 1;

Choose a reason for hiding this comment

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

Typo: the second condition should be pointerEvent.clientY - this.down_.clientY.

One question: Any chance the threshold 1 may be too large? The real offset that are causing the bug seems well below 1. May be 0.5 or even 0.9 is a better alternative?

Copy link

Choose a reason for hiding this comment

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

I'm using 1 and works fine

Copy link

Choose a reason for hiding this comment

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

I have problems handling the two fingers in order to make a pinch zoom...

Copy link
Member Author

Choose a reason for hiding this comment

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

oups, thanks @mustaqahmed

Copy link
Member Author

Choose a reason for hiding this comment

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

CodePen updated

@ischas
Copy link
Contributor

ischas commented May 8, 2017

For me it's nearly impossible to select a country in this demo:
http://openlayers.org/en/latest/examples/select-features.html

The linked CodePen works for me (but I guess @mustaqahmed is right with its review comment).

@fredj fredj force-pushed the isMoving_tolerance branch 2 times, most recently from 7895301 to 7b719cd Compare May 9, 2017 12:17
@fredj
Copy link
Member Author

fredj commented May 9, 2017

I changed the threshold to 0.75 as suggested and updated the CodePen.

@ischas
Copy link
Contributor

ischas commented May 9, 2017

Now selecting is better than with master, but less easy as with the first commit.

@fredj
Copy link
Member Author

fredj commented May 9, 2017

@ischas back to 1px, CodePen updated

@ischas
Copy link
Contributor

ischas commented May 9, 2017

@simonseyock and I tested on my Samsung S5 with Android 6.0.1 and Chrome 58.

While with the select feature demo only round about every fifth to tenth touch is registered as touch, with the CodePen maybe every second touch is registered as touch. That's much better, but not good.

Please consider that the first commit behaved "better" in context of selection because of the bug and isMoving_ always returning false. So I'm not sure if my former observation of decreased selectability depends on the threshold.

@fredj
Copy link
Member Author

fredj commented May 10, 2017

I tested on a Samsung S6 and it's not working. I've added the devicePixelRatio into the mix

@ischas
Copy link
Contributor

ischas commented May 10, 2017

CodePen now works fine for me.

@fredj
Copy link
Member Author

fredj commented May 10, 2017

@ischas and are the pan, pinch zoom and rotate working as well?

@fredj
Copy link
Member Author

fredj commented May 10, 2017

@simonseyock can you also test on the phone that doesn't have the issue if everything continues to work as expected?

@ischas
Copy link
Contributor

ischas commented May 10, 2017

I Tested tap, double tap, pan, pinch zoom, rotate, everything's fine. Did I miss anything else?

@simonseyock is out of office until Friday, but maybe he'll find some time for testing in its spare time. ;-)

@fredj
Copy link
Member Author

fredj commented May 10, 2017

I'm tested with a Nexus 5x (doesn't have the issue) and it works as expected

@ghost
Copy link

ghost commented May 10, 2017

Tested Nexus 4, Android 5.1.1, Chrome 58.0.3029.83 - previously had the issue now working fine.

@fredj
Copy link
Member Author

fredj commented May 10, 2017

@openlayers/core thanks for any review

Copy link
Member

@ahocevar ahocevar left a comment

Choose a reason for hiding this comment

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

Code looks good, I only added one minor remark.

* @type {number}
* @private
*/
this.moveTolerance_ = 1 * ol.has.DEVICE_PIXEL_RATIO;
Copy link
Member

Choose a reason for hiding this comment

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

The 1 * is unnecessary.

@fredj fredj merged commit aced2e4 into openlayers:master May 11, 2017
@fredj fredj deleted the isMoving_tolerance branch May 11, 2017 07:43
@ischas
Copy link
Contributor

ischas commented May 11, 2017

Any chance for a patch release?

@mbj4668
Copy link

mbj4668 commented May 11, 2017

I have tested the CodePen with a Sony Z3 Compact, Android 6.0.1, Chrome 58.0.3029.83, and I still have problems selecting countries. It works slightly better than http://openlayers.org/en/latest/examples/select-features.html, but not good.

I have also tested with a Sony Z4 Tablet, Android 7.0, Chrome 58.0.3029.83, and there the CodePen works fine, and the select-features example does not work.

@fredj
Copy link
Member Author

fredj commented May 12, 2017

What's the device pixel ratio of these devices ? see http://devicepixelratio.com/

@mbj4668
Copy link

mbj4668 commented May 12, 2017 via email

@mbj4668
Copy link

mbj4668 commented May 12, 2017

Update: when I applied your patch to my 4.1.1-based application, my application now works as it should on the phone (using 1.5 * ol.has.DEVICE_PIXEL_RATIO) gives even better result (i.e., with a factor of 1 some taps are still missed)). But the codepen above still doesn't work; I have tried it several times.

@joaodiasafonso
Copy link

Hello.
I am facing this problem since Android webview was updated. If I uninstall latest version and stick to default one, it starts working.
Anyway, none of the workarounds/samples in this conversation worked for me. My device's pixel ratio is 4.
Thanks in advance. Regards,

@joaodiasafonso
Copy link

Need to make a correction because I was only checking in codepen and ol samples: after properly make @fredj update in library js, it began working as supposed. So, this has worked for me.

@jhwegener
Copy link

Nice PR, thanks @fredj !
Is there any chance to get a patch release for this?

@ahocevar
Copy link
Member

ahocevar commented Jun 6, 2017

We'll be releasing v4.2.0 in the next couple of days anyway.

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.

Tapping on map on Android doesn't always work after a Chrome fix
9 participants