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

Another blind attemp to work around dblclicks on Edge #5268

Merged
merged 2 commits into from Jan 23, 2017
Merged

Conversation

IvanSanchez
Copy link
Member

@IvanSanchez IvanSanchez commented Jan 19, 2017

With a bit of luck this will fix #5180.

I've copy-pasted this patch into a playground here: https://playground-leaflet.rhcloud.com/kunur/1/edit?html,output - will appreciate testing. cc @perliedman @hyperknot @davetimmins timlohnes

There is also #5267, with a different approach

@@ -17,9 +17,7 @@ L.extend(L.DomEvent, {
var count;

if (L.Browser.pointer) {
if ((!L.Browser.edge) || e.pointerType === 'mouse') {
Copy link
Member Author

Choose a reason for hiding this comment

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

This code won't run on anything but Edge anyway (Chrome+pointer listens only for native dblclicks), so the extra check is not needed.

@@ -38,6 +36,8 @@ L.extend(L.DomEvent, {
function onTouchEnd() {
if (doubleTap && !touch.cancelBubble) {
if (L.Browser.pointer) {
if (e.pointerType === 'mouse') { return; }
Copy link
Member Author

Choose a reason for hiding this comment

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

This is why #5180 was firing dblclicks on mouse after a touchscreen double-tap: the doubleTap flag is set after a double-tap.

obj.addEventListener('dblclick', handler, false);
}
// Edge 14 also fires native dblclicks, but only for pointerType mouse, see #5180.
obj.addEventListener('dblclick', handler, false);
Copy link
Member Author

Choose a reason for hiding this comment

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

This changes the strategy for Edge: always listen for native dblblicks, but ignore the pointerType mouse later.

@@ -77,7 +77,10 @@ L.DomEvent = {
if (L.Browser.pointer && type.indexOf('touch') === 0) {
this.addPointerListener(obj, type, handler, id);

} else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
} else if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener &&
!(L.Browser.pointer && L.Browser.chrome) ) {
Copy link
Member Author

Choose a reason for hiding this comment

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

This makes chrome>55 ignore the addDoubleTapListener hack and rely on native dblclicks only.

@davetimmins
Copy link

Looks to be working as expected now 👍

@IvanSanchez
Copy link
Member Author

Seems to be working as expected on:

  • Edge 14 (as tested by @davetimmins and @perliedman) (native on mouse, synthetic on touch)
  • Safari 9 on iPad2 (fires synthetic)
  • IEMobile 11 on WinPhone 8.1 (fires native)
  • Chrome 57 on Android 6 (fires native)
  • Chrome 55 on desktop (fires native)
  • Firefox 51 on desktop (fires native)
  • Firefox 51 on Android 6 (fires synthetic)

@hyperknot
Copy link
Collaborator

Leaflet 1.0.2+ad27106
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36
pointerdown pointer (mouse)
mousedown mouse (1)
pointerup pointer (mouse)
mouseup mouse (1)
click mouse (1)
pointerdown pointer (mouse)
mousedown mouse (2)
pointerup pointer (mouse)
mouseup mouse (2)
click mouse (2)
dblclick mouse (2)

Copy link
Member

@perliedman perliedman left a comment

Choose a reason for hiding this comment

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

LGTM, I tested it with touch in Win10 on Chrome55, IE11 and Edge 14.

@perliedman perliedman merged commit 2b5d401 into master Jan 23, 2017
@IvanSanchez IvanSanchez deleted the pointy-edge-2 branch January 23, 2017 10:05
johnd0e pushed a commit to johnd0e/Leaflet that referenced this pull request Mar 12, 2020
mourner pushed a commit that referenced this pull request Mar 20, 2020
* Prevent Browser.chrome = true for pre-Chromium Edge

Sample user agent string:
"Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/18.17763"

* fixup! Another blind attemp to work around dblclicks on Edge (#5268)

Fix leftover that was meant to change in 2b5d401
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.

Duplicated 'dblclick' and phantom 'touchstart' events with Chrome >= 55
4 participants