Cleaned up ol/pointer classes

This commit is contained in:
Tim Schaub
2018-07-17 17:48:27 -06:00
parent d855f5ba0a
commit 069187859d
7 changed files with 460 additions and 453 deletions

View File

@@ -1,42 +1,45 @@
/**
* @module ol/pointer/EventSource
*/
/**
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
* @param {!Object.<string, function(Event)>} mapping Event mapping.
* @constructor
*/
class EventSource {
/**
* @param {module:ol/pointer/PointerEventHandler} dispatcher Event handler.
* @param {!Object.<string, function(Event)>} mapping Event mapping.
*/
constructor(dispatcher, mapping) {
/**
* @type {module:ol/pointer/PointerEventHandler}
*/
* @type {module:ol/pointer/PointerEventHandler}
*/
this.dispatcher = dispatcher;
/**
* @private
* @const
* @type {!Object.<string, function(Event)>}
*/
* @private
* @const
* @type {!Object.<string, function(Event)>}
*/
this.mapping_ = mapping;
}
/**
* List of events supported by this source.
* @return {Array.<string>} Event names
*/
* List of events supported by this source.
* @return {Array.<string>} Event names
*/
getEvents() {
return Object.keys(this.mapping_);
}
/**
* Returns the handler that should handle a given event type.
* @param {string} eventType The event type.
* @return {function(Event)} Handler
*/
* Returns the handler that should handle a given event type.
* @param {string} eventType The event type.
* @return {function(Event)} Handler
*/
getHandlerForEvent(eventType) {
return this.mapping_[eventType];
}
}
export default EventSource;