diff --git a/src/ol/interaction/doubleclickzoominteraction.js b/src/ol/interaction/doubleclickzoominteraction.js index 29fb5050b4..53a70ae951 100644 --- a/src/ol/interaction/doubleclickzoominteraction.js +++ b/src/ol/interaction/doubleclickzoominteraction.js @@ -41,6 +41,7 @@ goog.inherits(ol.interaction.DoubleClickZoom, ol.interaction.Interaction); */ ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + var stopEvent = false; var browserEvent = mapBrowserEvent.browserEvent; if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DBLCLICK && mapBrowserEvent.isMouseActionButton()) { @@ -52,6 +53,7 @@ ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent = ol.interaction.Interaction.zoomByDelta(map, view, delta, anchor, ol.interaction.DOUBLECLICKZOOM_ANIMATION_DURATION); mapBrowserEvent.preventDefault(); - mapBrowserEvent.stopOtherInteractions(); + stopEvent = true; } + return !stopEvent; }; diff --git a/src/ol/interaction/draginteraction.js b/src/ol/interaction/draginteraction.js index a4ed459161..3bcbc3ac93 100644 --- a/src/ol/interaction/draginteraction.js +++ b/src/ol/interaction/draginteraction.js @@ -95,8 +95,9 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { var map = mapBrowserEvent.map; if (!map.isDef()) { - return; + return true; } + var stopEvent = false; var view = map.getView(); var browserEvent = mapBrowserEvent.browserEvent; if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.DOWN) { @@ -132,7 +133,8 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent = view.setHint(ol.ViewHint.INTERACTING, 1); this.dragging_ = true; mapBrowserEvent.preventDefault(); - mapBrowserEvent.stopOtherInteractions(); + stopEvent = true; } } + return !stopEvent; }; diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index 11fa586d6b..6fb94e17a7 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -17,6 +17,9 @@ ol.interaction.Interaction = function() { /** * @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event. + * @return {boolean} Whether the map browser event should continue + * through the chain of interactions. false means stop, true + * means continue. */ ol.interaction.Interaction.prototype.handleMapBrowserEvent = goog.abstractMethod; diff --git a/src/ol/interaction/keyboardpaninteraction.js b/src/ol/interaction/keyboardpaninteraction.js index 7ebd1fd329..b52c7108a3 100644 --- a/src/ol/interaction/keyboardpaninteraction.js +++ b/src/ol/interaction/keyboardpaninteraction.js @@ -52,6 +52,7 @@ goog.inherits(ol.interaction.KeyboardPan, ol.interaction.Interaction); */ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + var stopEvent = false; if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) { var keyEvent = /** @type {goog.events.KeyEvent} */ (mapBrowserEvent.browserEvent); @@ -81,7 +82,8 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent = ol.interaction.Interaction.pan( map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION); mapBrowserEvent.preventDefault(); - mapBrowserEvent.stopOtherInteractions(); + stopEvent = true; } } + return !stopEvent; }; diff --git a/src/ol/interaction/keyboardzoominteraction.js b/src/ol/interaction/keyboardzoominteraction.js index bf23e2adfa..f7b193179d 100644 --- a/src/ol/interaction/keyboardzoominteraction.js +++ b/src/ol/interaction/keyboardzoominteraction.js @@ -49,6 +49,7 @@ goog.inherits(ol.interaction.KeyboardZoom, ol.interaction.Interaction); */ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + var stopEvent = false; if (mapBrowserEvent.type == goog.events.KeyHandler.EventType.KEY) { var keyEvent = /** @type {goog.events.KeyEvent} */ (mapBrowserEvent.browserEvent); @@ -63,7 +64,8 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent = ol.interaction.Interaction.zoomByDelta(map, view, delta, undefined, ol.interaction.KEYBOARD_ZOOM_DURATION); mapBrowserEvent.preventDefault(); - mapBrowserEvent.stopOtherInteractions(); + stopEvent = true; } } + return !stopEvent; }; diff --git a/src/ol/interaction/mousewheelzoominteraction.js b/src/ol/interaction/mousewheelzoominteraction.js index 2042565c5e..cb21af1dd0 100644 --- a/src/ol/interaction/mousewheelzoominteraction.js +++ b/src/ol/interaction/mousewheelzoominteraction.js @@ -70,7 +70,7 @@ goog.inherits(ol.interaction.MouseWheelZoom, ol.interaction.Interaction); */ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { - + var stopEvent = false; if (mapBrowserEvent.type == goog.events.MouseWheelHandler.EventType.MOUSEWHEEL) { var map = mapBrowserEvent.map; @@ -93,8 +93,9 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent = goog.bind(this.doZoom_, this, map), timeLeft); mapBrowserEvent.preventDefault(); - mapBrowserEvent.stopOtherInteractions(); + stopEvent = true; } + return !stopEvent; }; diff --git a/src/ol/interaction/touchinteraction.js b/src/ol/interaction/touchinteraction.js index b19b1e5d51..f1d258a223 100644 --- a/src/ol/interaction/touchinteraction.js +++ b/src/ol/interaction/touchinteraction.js @@ -126,4 +126,5 @@ ol.interaction.Touch.prototype.handleMapBrowserEvent = } this.handled_ = handled; } + return true; }; diff --git a/src/ol/map.js b/src/ol/map.js index 75f8519ccd..5c4fad875c 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -672,8 +672,8 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { if (this.dispatchEvent(mapBrowserEvent) !== false) { for (i = interactionsArray.length - 1; i >= 0; i--) { var interaction = interactionsArray[i]; - interaction.handleMapBrowserEvent(mapBrowserEvent); - if (mapBrowserEvent.otherInteractionsStopped) { + var cont = interaction.handleMapBrowserEvent(mapBrowserEvent); + if (!cont) { break; } } diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index a277ea6057..aed9f2f769 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -39,11 +39,6 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) { */ this.coordinate_ = null; - /** - * @type {boolean} - */ - this.otherInteractionsStopped = false; - /** * @private * @type {ol.Pixel} @@ -114,14 +109,6 @@ ol.MapBrowserEvent.prototype.preventDefault = function() { }; -/** - * Stop the interaction chain. - */ -ol.MapBrowserEvent.prototype.stopOtherInteractions = function() { - this.otherInteractionsStopped = true; -}; - - /** * Prevents further propagation of the current event. * @see https://developer.mozilla.org/en-US/docs/Web/API/event.stopPropagation