openlayers / ol2

OpenLayers v2 - deprecated!
Other
1.48k stars 771 forks source link

Button trigger not fired on touch enabled devices using google chrome and mouse click #1495

Closed npgeomap closed 8 years ago

npgeomap commented 8 years ago

Trigger event gets not fired in Chrome using OpenLayers.Control.Button on touch enabled devices on mouse click - but works on touch. No Problems in current FireFox, Internet Explorer and Microsoft Edge

Can be verified in the Openlayers two default samples (you need a touch enabled device ;)

npgeomap commented 8 years ago

Got it. The reason is the change done by @pgiraud: Don't listen to mouse events if the device is touch capable:https://github.com/openlayers/ol2/commit/9a4f5d17626583a332099aa1a8a93e01467546bb

I don't know why someone would disable buttonClick Events just because the screen is touch enabled. Unfortunatelly @pgiraud didnt leave a description or a reason for the changes he did. Nowadays many notebooks come with touchscreens but the users still take the mouse or even use both devices. I revert the changes and now both works just perfect. And the reason why it occurs only in chrome was that the new added "isDeviceTouchCapable" property didn't work properly. Only Chrome responds true.

Hope this helps others in the same trap.

marcjansen commented 8 years ago

I think @pgiraud fixed #1216 with that commit. Can you observe if you experience sth. that is mentioned over there?

npgeomap commented 8 years ago

Yes, it is possible that on some older Android devices the https://github.com/openlayers/ol2/issues/1216 issue occurs. But since more and more mixed devices (Mouse/Touch) are in use, I think the possibility that the buttons are locked due to this commit is very high.

The condition @pgiraud added prevents buttonClick on all mixed devices! if (element && (OpenLayers.Event.isLeftClick(evt) && !this.isDeviceTouchCapable ||!~evt.type.indexOf("mouse")))

I already tested the reverted version on following devices:

Browser: Chrome, Firefox, IE, Edge ButtonClick and/or Touch works on all this devices and did not raise a second click.

But if the issue still occurs on some older Android devices, we need an other solution instead of preventing any ButtonClick.