Pass the mapping object to the ol.pointer.EventSource constructor
Conflicts: src/ol/pointer/mssource.js
This commit is contained in:
committed by
tsauerwein
parent
4468d96a13
commit
028a183d11
@@ -2,18 +2,27 @@
|
||||
goog.provide('ol.pointer.EventSource');
|
||||
|
||||
goog.require('goog.events.BrowserEvent');
|
||||
goog.require('goog.object');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.pointer.PointerEventHandler} dispatcher
|
||||
* @param {Object.<string, function(goog.events.BrowserEvent)>} mapping
|
||||
* @constructor
|
||||
*/
|
||||
ol.pointer.EventSource = function(dispatcher) {
|
||||
ol.pointer.EventSource = function(dispatcher, mapping) {
|
||||
/**
|
||||
* @type {ol.pointer.PointerEventHandler}
|
||||
*/
|
||||
this.dispatcher = dispatcher;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @const
|
||||
* @type {Object.<string, function(goog.events.BrowserEvent)>}
|
||||
*/
|
||||
this.mapping_ = mapping;
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +30,9 @@ ol.pointer.EventSource = function(dispatcher) {
|
||||
* List of events supported by this source.
|
||||
* @return {Array.<string>} Event names
|
||||
*/
|
||||
ol.pointer.EventSource.prototype.getEvents = goog.abstractMethod;
|
||||
ol.pointer.EventSource.prototype.getEvents = function() {
|
||||
return goog.object.getKeys(this.mapping_);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -30,7 +41,9 @@ ol.pointer.EventSource.prototype.getEvents = goog.abstractMethod;
|
||||
* @return {Object.<string, function(goog.events.BrowserEvent)>}
|
||||
* Event/Handler mapping
|
||||
*/
|
||||
ol.pointer.EventSource.prototype.getMapping = goog.abstractMethod;
|
||||
ol.pointer.EventSource.prototype.getMapping = function() {
|
||||
return this.mapping_;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,5 +52,5 @@ ol.pointer.EventSource.prototype.getMapping = goog.abstractMethod;
|
||||
* @return {function(goog.events.BrowserEvent)} Handler
|
||||
*/
|
||||
ol.pointer.EventSource.prototype.getHandlerForEvent = function(eventType) {
|
||||
return this.getMapping()[eventType];
|
||||
return this.mapping_[eventType];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user