Remove ol.MapBrowserEvent#stopOtherInteractions
and check for false/true in the return from handleMapBrowserEvent. Refs #791.
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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) {
|
||||
@@ -131,7 +132,8 @@ ol.interaction.Drag.prototype.handleMapBrowserEvent =
|
||||
view.setHint(ol.ViewHint.INTERACTING, 1);
|
||||
this.dragging_ = true;
|
||||
mapBrowserEvent.preventDefault();
|
||||
mapBrowserEvent.stopOtherInteractions();
|
||||
stopEvent = true;
|
||||
}
|
||||
}
|
||||
return !stopEvent;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -126,4 +126,5 @@ ol.interaction.Touch.prototype.handleMapBrowserEvent =
|
||||
}
|
||||
this.handled_ = handled;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -667,8 +667,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user