Dispatch MapBrowserEvent before interactions get it

By doing so, application event handlers can preventDefault on the event, and interactions won't get the event any more. This means that interactions are default behavior that can be prevented by application event handlers.
This commit is contained in:
ahocevar
2012-09-27 09:54:16 +02:00
parent d3b9af30d0
commit 1b18dbedb7

View File

@@ -490,11 +490,12 @@ ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
var interactions = this.getInteractions();
var interactionsArray = /** @type {Array.<ol.interaction.Interaction>} */
interactions.getArray();
goog.array.every(interactionsArray, function(interaction) {
interaction.handleMapBrowserEvent(mapBrowserEvent);
return !mapBrowserEvent.defaultPrevented;
});
this.dispatchEvent(mapBrowserEvent);
if (this.dispatchEvent(mapBrowserEvent) !== false) {
goog.array.every(interactionsArray, function(interaction) {
interaction.handleMapBrowserEvent(mapBrowserEvent);
return !mapBrowserEvent.defaultPrevented;
});
}
};