Emulate click events only on mouse "action"

`click` events are fired only if the mouse action button is pressed. This prevents `click` events from being fired when the middle mouse button is used.

Also, without this commit, in Chrome with emulated touch events enabled, double-clicking the map doesn't zoom the map. This is because `ol.BrowserFeature.HAS_TOUCH` is `false` in that environment. The commit fixes it by testing `isMouseActionButton` on mouse devices only.
This commit is contained in:
Éric Lemoine
2013-10-29 15:58:22 +01:00
parent 0c212fdcb5
commit a85b82090d
2 changed files with 2 additions and 14 deletions

View File

@@ -46,8 +46,7 @@ ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) {
var stopEvent = false;
var browserEvent = mapBrowserEvent.browserEvent;
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DBLCLICK &&
mapBrowserEvent.isMouseActionButton()) {
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DBLCLICK) {
var map = mapBrowserEvent.map;
var anchor = mapBrowserEvent.getCoordinate();
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;