Add a frameState property to ol.MapBrowserEvent

so that we will be able to retrieve the current center of the view2d from the
framestate in the dragpan interaction.
This commit is contained in:
Bruno Binet
2013-01-29 13:00:02 +01:00
parent d54864695d
commit 39cbba3eb7
2 changed files with 9 additions and 3 deletions

View File

@@ -542,6 +542,7 @@ ol.Map.prototype.handleControlsRemove_ = function(collectionEvent) {
* @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle. * @param {ol.MapBrowserEvent} mapBrowserEvent The event to handle.
*/ */
ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { ol.Map.prototype.handleMapBrowserEvent = function(mapBrowserEvent) {
mapBrowserEvent.frameState = this.frameState_;
var interactions = this.getInteractions(); var interactions = this.getInteractions();
var interactionsArray = /** @type {Array.<ol.interaction.Interaction>} */ var interactionsArray = /** @type {Array.<ol.interaction.Interaction>} */
(interactions.getArray()); (interactions.getArray());

View File

@@ -21,10 +21,11 @@ goog.require('ol.Pixel');
* @param {string} type Event type. * @param {string} type Event type.
* @param {ol.Map} map Map. * @param {ol.Map} map Map.
* @param {goog.events.BrowserEvent} browserEvent Browser event. * @param {goog.events.BrowserEvent} browserEvent Browser event.
* @param {?ol.FrameState=} opt_frameState Frame state.
*/ */
ol.MapBrowserEvent = function(type, map, browserEvent) { ol.MapBrowserEvent = function(type, map, browserEvent, opt_frameState) {
goog.base(this, type, map); goog.base(this, type, map, opt_frameState);
/** /**
* @type {goog.events.BrowserEvent} * @type {goog.events.BrowserEvent}
@@ -230,6 +231,9 @@ ol.MapBrowserEventHandler.prototype.handleUp_ = function(browserEvent) {
* @private * @private
*/ */
ol.MapBrowserEventHandler.prototype.handleDown_ = function(browserEvent) { ol.MapBrowserEventHandler.prototype.handleDown_ = function(browserEvent) {
var newEvent = new ol.MapBrowserEvent(
ol.MapBrowserEvent.EventType.DOWN, this.map_, browserEvent);
this.dispatchEvent(newEvent);
if (!this.previous_) { if (!this.previous_) {
this.touchEnableBrowserEvent_(browserEvent); this.touchEnableBrowserEvent_(browserEvent);
this.down_ = browserEvent; this.down_ = browserEvent;
@@ -306,5 +310,6 @@ ol.MapBrowserEvent.EventType = {
DBLCLICK: goog.events.EventType.DBLCLICK, DBLCLICK: goog.events.EventType.DBLCLICK,
DRAGSTART: 'dragstart', DRAGSTART: 'dragstart',
DRAG: 'drag', DRAG: 'drag',
DRAGEND: 'dragend' DRAGEND: 'dragend',
DOWN: 'down'
}; };