Add ol.MapBrowserEvent.stopOtherInteractions

When called, stops the interaction chain.
This commit is contained in:
Frederic Junod
2013-06-18 12:59:30 +02:00
parent 2bd87313cd
commit bed44dd82c
6 changed files with 18 additions and 1 deletions

View File

@@ -52,5 +52,6 @@ ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent =
ol.interaction.Interaction.zoomByDelta(map, view, delta, anchor,
ol.interaction.DOUBLECLICKZOOM_ANIMATION_DURATION);
mapBrowserEvent.preventDefault();
mapBrowserEvent.stopOtherInteractions();
}
};

View File

@@ -82,6 +82,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
ol.interaction.Interaction.pan(
map, view, delta, ol.interaction.KEYBOARD_PAN_DURATION);
mapBrowserEvent.preventDefault();
mapBrowserEvent.stopOtherInteractions();
}
}
};

View File

@@ -63,6 +63,7 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
ol.interaction.Interaction.zoomByDelta(map, view, delta, undefined,
ol.interaction.KEYBOARD_ZOOM_DURATION);
mapBrowserEvent.preventDefault();
mapBrowserEvent.stopOtherInteractions();
}
}
};

View File

@@ -93,6 +93,7 @@ ol.interaction.MouseWheelZoom.prototype.handleMapBrowserEvent =
goog.bind(this.doZoom_, this, map), timeLeft);
mapBrowserEvent.preventDefault();
mapBrowserEvent.stopOtherInteractions();
}
};

View File

@@ -644,7 +644,7 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
for (i = interactionsArray.length - 1; i >= 0; i--) {
var interaction = interactionsArray[i];
interaction.handleMapBrowserEvent(mapBrowserEvent);
if (mapBrowserEvent.defaultPrevented) {
if (mapBrowserEvent.otherInteractionsStopped) {
break;
}
}

View File

@@ -39,6 +39,11 @@ ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {
*/
this.coordinate_ = null;
/**
* @type {boolean}
*/
this.otherInteractionsStopped = false;
/**
* @private
* @type {ol.Pixel}
@@ -107,6 +112,14 @@ ol.MapBrowserEvent.prototype.preventDefault = function() {
};
/**
* Stop the interaction chain.
*/
ol.MapBrowserEvent.prototype.stopOtherInteractions = function() {
this.otherInteractionsStopped = true;
};
/**
* @override
*/