From 9bd507e9b8e1924e05be2733cf934c8a026e1fe7 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Thu, 21 Jun 2012 19:27:18 +0200 Subject: [PATCH] Adding a map of sequence providers --- src/ol/Map.js | 14 +++++++++++++- src/ol/event/Drag.js | 3 +++ src/ol/event/Events.js | 30 ++++++++++++++++++------------ test/spec/ol/Events.test.js | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/ol/Map.js b/src/ol/Map.js index 19585b1846..dc91e4a4ac 100644 --- a/src/ol/Map.js +++ b/src/ol/Map.js @@ -80,12 +80,24 @@ ol.Map = function() { */ this.viewport_ = null; + /** + * @private + * @type {Element} + */ + this.mapOverlay_ = null; + + /** + * @private + * @type {Element} + */ + this.staticOverlay_ = null; + /** * @private * @type {ol.event.Events} */ this.events_ = new ol.event.Events( - this, undefined, false, ['Drag'] + this, undefined, false, ['drag'] ); /** diff --git a/src/ol/event/Drag.js b/src/ol/event/Drag.js index 6b8fad4d62..869fc2eb83 100644 --- a/src/ol/event/Drag.js +++ b/src/ol/event/Drag.js @@ -2,6 +2,7 @@ goog.provide('ol.event.Drag'); goog.provide('ol.event.DragEvent'); goog.require('ol.event.ISequence'); +goog.require('ol.event.Events'); goog.require('goog.functions'); goog.require('goog.fx.Dragger'); goog.require('goog.fx.DragEvent'); @@ -74,6 +75,8 @@ ol.event.Drag.prototype.getEventTypes = function() { /** @inheritDoc */ ol.event.Drag.prototype.destroy = ol.event.Drag.prototype.dispose; +ol.event.addSequenceProvider('drag', ol.event.Drag); + /** * Object representing a drag event diff --git a/src/ol/event/Events.js b/src/ol/event/Events.js index 4551744213..470b4b2a3e 100644 --- a/src/ol/event/Events.js +++ b/src/ol/event/Events.js @@ -7,12 +7,24 @@ goog.require('goog.events.EventTarget'); goog.require('goog.events.Listener'); goog.require('goog.style'); +/** + * @enum {Object} + */ +ol.event.SEQUENCE_PROVIDER_MAP = {}; + +/** + * @param {string} name + * @param {Function} obj + */ +ol.event.addSequenceProvider = function(name, obj) { + ol.event.SEQUENCE_PROVIDER_MAP[name] = obj; +}; + /** * Determine whether event was caused by a single touch * * @param {!Event} evt * @return {boolean} - * @export */ ol.event.isSingleTouch = function(evt) { return !!(evt.touches && evt.touches.length == 1); @@ -23,7 +35,6 @@ ol.event.isSingleTouch = function(evt) { * * @param {!Event} evt * @return {boolean} - * @export */ ol.event.isMultiTouch = function(evt) { return !!(evt.touches && evt.touches.length > 1); @@ -46,7 +57,6 @@ ol.event.isMultiTouch = function(evt) { * false. * @param {Array.=} opt_sequences Event sequences to register with * this Events instance. - * @export */ ol.event.Events = function(object, opt_element, opt_includeXY, opt_sequences) { @@ -92,7 +102,6 @@ goog.inherits(ol.event.Events, goog.events.EventTarget); /** * @return {Object} The object that this instance is bound to. - * @export */ ol.event.Events.prototype.getObject = function() { return this.object_; @@ -100,7 +109,6 @@ ol.event.Events.prototype.getObject = function() { /** * @param {boolean} includeXY - * @export */ ol.event.Events.prototype.setIncludeXY = function(includeXY) { this.includeXY_ = includeXY; @@ -109,7 +117,6 @@ ol.event.Events.prototype.setIncludeXY = function(includeXY) { /** * @return {EventTarget} The element that this instance currently * listens to browser events on. - * @export */ ol.event.Events.prototype.getElement = function() { return this.element_; @@ -122,7 +129,6 @@ ol.event.Events.prototype.getElement = function() { * @param {EventTarget} element A DOM element to attach * browser events to. If called without this argument, all browser events * will be detached from the element they are currently attached to. - * @export */ ol.event.Events.prototype.setElement = function(element) { var types, t; @@ -155,7 +161,11 @@ ol.event.Events.prototype.setElement = function(element) { */ ol.event.Events.prototype.createSequences = function(target) { for (var i=0, ii=this.sequenceProviders_.length; i