Adding a map of sequence providers
This commit is contained in:
+13
-1
@@ -80,12 +80,24 @@ ol.Map = function() {
|
|||||||
*/
|
*/
|
||||||
this.viewport_ = null;
|
this.viewport_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Element}
|
||||||
|
*/
|
||||||
|
this.mapOverlay_ = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {Element}
|
||||||
|
*/
|
||||||
|
this.staticOverlay_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.event.Events}
|
* @type {ol.event.Events}
|
||||||
*/
|
*/
|
||||||
this.events_ = new ol.event.Events(
|
this.events_ = new ol.event.Events(
|
||||||
this, undefined, false, ['Drag']
|
this, undefined, false, ['drag']
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ goog.provide('ol.event.Drag');
|
|||||||
goog.provide('ol.event.DragEvent');
|
goog.provide('ol.event.DragEvent');
|
||||||
|
|
||||||
goog.require('ol.event.ISequence');
|
goog.require('ol.event.ISequence');
|
||||||
|
goog.require('ol.event.Events');
|
||||||
goog.require('goog.functions');
|
goog.require('goog.functions');
|
||||||
goog.require('goog.fx.Dragger');
|
goog.require('goog.fx.Dragger');
|
||||||
goog.require('goog.fx.DragEvent');
|
goog.require('goog.fx.DragEvent');
|
||||||
@@ -74,6 +75,8 @@ ol.event.Drag.prototype.getEventTypes = function() {
|
|||||||
/** @inheritDoc */
|
/** @inheritDoc */
|
||||||
ol.event.Drag.prototype.destroy = ol.event.Drag.prototype.dispose;
|
ol.event.Drag.prototype.destroy = ol.event.Drag.prototype.dispose;
|
||||||
|
|
||||||
|
ol.event.addSequenceProvider('drag', ol.event.Drag);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing a drag event
|
* Object representing a drag event
|
||||||
|
|||||||
+18
-12
@@ -7,12 +7,24 @@ goog.require('goog.events.EventTarget');
|
|||||||
goog.require('goog.events.Listener');
|
goog.require('goog.events.Listener');
|
||||||
goog.require('goog.style');
|
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
|
* Determine whether event was caused by a single touch
|
||||||
*
|
*
|
||||||
* @param {!Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.isSingleTouch = function(evt) {
|
ol.event.isSingleTouch = function(evt) {
|
||||||
return !!(evt.touches && evt.touches.length == 1);
|
return !!(evt.touches && evt.touches.length == 1);
|
||||||
@@ -23,7 +35,6 @@ ol.event.isSingleTouch = function(evt) {
|
|||||||
*
|
*
|
||||||
* @param {!Event} evt
|
* @param {!Event} evt
|
||||||
* @return {boolean}
|
* @return {boolean}
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.isMultiTouch = function(evt) {
|
ol.event.isMultiTouch = function(evt) {
|
||||||
return !!(evt.touches && evt.touches.length > 1);
|
return !!(evt.touches && evt.touches.length > 1);
|
||||||
@@ -46,7 +57,6 @@ ol.event.isMultiTouch = function(evt) {
|
|||||||
* false.
|
* false.
|
||||||
* @param {Array.<String>=} opt_sequences Event sequences to register with
|
* @param {Array.<String>=} opt_sequences Event sequences to register with
|
||||||
* this Events instance.
|
* this Events instance.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events = function(object, opt_element, opt_includeXY, opt_sequences) {
|
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.
|
* @return {Object} The object that this instance is bound to.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.getObject = function() {
|
ol.event.Events.prototype.getObject = function() {
|
||||||
return this.object_;
|
return this.object_;
|
||||||
@@ -100,7 +109,6 @@ ol.event.Events.prototype.getObject = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} includeXY
|
* @param {boolean} includeXY
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.setIncludeXY = function(includeXY) {
|
ol.event.Events.prototype.setIncludeXY = function(includeXY) {
|
||||||
this.includeXY_ = includeXY;
|
this.includeXY_ = includeXY;
|
||||||
@@ -109,7 +117,6 @@ ol.event.Events.prototype.setIncludeXY = function(includeXY) {
|
|||||||
/**
|
/**
|
||||||
* @return {EventTarget} The element that this instance currently
|
* @return {EventTarget} The element that this instance currently
|
||||||
* listens to browser events on.
|
* listens to browser events on.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.getElement = function() {
|
ol.event.Events.prototype.getElement = function() {
|
||||||
return this.element_;
|
return this.element_;
|
||||||
@@ -122,7 +129,6 @@ ol.event.Events.prototype.getElement = function() {
|
|||||||
* @param {EventTarget} element A DOM element to attach
|
* @param {EventTarget} element A DOM element to attach
|
||||||
* browser events to. If called without this argument, all browser events
|
* browser events to. If called without this argument, all browser events
|
||||||
* will be detached from the element they are currently attached to.
|
* will be detached from the element they are currently attached to.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.setElement = function(element) {
|
ol.event.Events.prototype.setElement = function(element) {
|
||||||
var types, t;
|
var types, t;
|
||||||
@@ -155,7 +161,11 @@ ol.event.Events.prototype.setElement = function(element) {
|
|||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.createSequences = function(target) {
|
ol.event.Events.prototype.createSequences = function(target) {
|
||||||
for (var i=0, ii=this.sequenceProviders_.length; i<ii; ++i) {
|
for (var i=0, ii=this.sequenceProviders_.length; i<ii; ++i) {
|
||||||
this.sequences_.push(new ol.event[this.sequenceProviders_[i]](target));
|
this.sequences_.push(
|
||||||
|
new ol.event.SEQUENCE_PROVIDER_MAP[this.sequenceProviders_[i]](
|
||||||
|
target
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -198,7 +208,6 @@ ol.event.Events.prototype.getBrowserEventTypes = function() {
|
|||||||
* property.
|
* property.
|
||||||
* @param {boolean=} opt_priority Register the listener as priority listener,
|
* @param {boolean=} opt_priority Register the listener as priority listener,
|
||||||
* so it gets executed before other listeners? Default is false.
|
* so it gets executed before other listeners? Default is false.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.register = function(type, listener, opt_scope,
|
ol.event.Events.prototype.register = function(type, listener, opt_scope,
|
||||||
opt_priority) {
|
opt_priority) {
|
||||||
@@ -215,7 +224,6 @@ ol.event.Events.prototype.register = function(type, listener, opt_scope,
|
|||||||
* @param {Object=} opt_scope The object to bind the context to for the
|
* @param {Object=} opt_scope The object to bind the context to for the
|
||||||
* listener. If no scope is specified, default is the event's default
|
* listener. If no scope is specified, default is the event's default
|
||||||
* scope.
|
* scope.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.unregister = function(type, listener, opt_scope) {
|
ol.event.Events.prototype.unregister = function(type, listener, opt_scope) {
|
||||||
goog.events.unlisten(
|
goog.events.unlisten(
|
||||||
@@ -231,7 +239,6 @@ ol.event.Events.prototype.unregister = function(type, listener, opt_scope) {
|
|||||||
*
|
*
|
||||||
* @return {boolean} The last listener return. If a listener returns false,
|
* @return {boolean} The last listener return. If a listener returns false,
|
||||||
* the chain of listeners will stop getting called.
|
* the chain of listeners will stop getting called.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.triggerEvent = function(type, opt_evt) {
|
ol.event.Events.prototype.triggerEvent = function(type, opt_evt) {
|
||||||
var returnValue,
|
var returnValue,
|
||||||
@@ -290,7 +297,6 @@ ol.event.Events.prototype.handleBrowserEvent = function(evt) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy this Events instance.
|
* Destroy this Events instance.
|
||||||
* @export
|
|
||||||
*/
|
*/
|
||||||
ol.event.Events.prototype.destroy = function() {
|
ol.event.Events.prototype.destroy = function() {
|
||||||
this.setElement(null);
|
this.setElement(null);
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ describe("ol.event.Events", function() {
|
|||||||
|
|
||||||
it("can be extended with event sequences", function() {
|
it("can be extended with event sequences", function() {
|
||||||
var element = document.createElement("div"),
|
var element = document.createElement("div"),
|
||||||
events = new ol.event.Events("foo", element, false, ["Drag"]),
|
events = new ol.event.Events("foo", element, false, ["drag"]),
|
||||||
mockEvt;
|
mockEvt;
|
||||||
|
|
||||||
// mock dom object
|
// mock dom object
|
||||||
|
|||||||
Reference in New Issue
Block a user