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.provide('ol.pointer.EventSource');
|
||||||
|
|
||||||
goog.require('goog.events.BrowserEvent');
|
goog.require('goog.events.BrowserEvent');
|
||||||
|
goog.require('goog.object');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.pointer.PointerEventHandler} dispatcher
|
* @param {ol.pointer.PointerEventHandler} dispatcher
|
||||||
|
* @param {Object.<string, function(goog.events.BrowserEvent)>} mapping
|
||||||
* @constructor
|
* @constructor
|
||||||
*/
|
*/
|
||||||
ol.pointer.EventSource = function(dispatcher) {
|
ol.pointer.EventSource = function(dispatcher, mapping) {
|
||||||
/**
|
/**
|
||||||
* @type {ol.pointer.PointerEventHandler}
|
* @type {ol.pointer.PointerEventHandler}
|
||||||
*/
|
*/
|
||||||
this.dispatcher = dispatcher;
|
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.
|
* List of events supported by this source.
|
||||||
* @return {Array.<string>} Event names
|
* @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)>}
|
* @return {Object.<string, function(goog.events.BrowserEvent)>}
|
||||||
* Event/Handler mapping
|
* 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
|
* @return {function(goog.events.BrowserEvent)} Handler
|
||||||
*/
|
*/
|
||||||
ol.pointer.EventSource.prototype.getHandlerForEvent = function(eventType) {
|
ol.pointer.EventSource.prototype.getHandlerForEvent = function(eventType) {
|
||||||
return this.getMapping()[eventType];
|
return this.mapping_[eventType];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.pointer.MouseSource');
|
goog.provide('ol.pointer.MouseSource');
|
||||||
|
|
||||||
goog.require('goog.object');
|
|
||||||
goog.require('ol.pointer.EventSource');
|
goog.require('ol.pointer.EventSource');
|
||||||
|
|
||||||
|
|
||||||
@@ -41,26 +40,20 @@ goog.require('ol.pointer.EventSource');
|
|||||||
* @extends {ol.pointer.EventSource}
|
* @extends {ol.pointer.EventSource}
|
||||||
*/
|
*/
|
||||||
ol.pointer.MouseSource = function(dispatcher) {
|
ol.pointer.MouseSource = function(dispatcher) {
|
||||||
goog.base(this, dispatcher);
|
var mapping = {
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {goog.structs.Map}
|
|
||||||
*/
|
|
||||||
this.pointerMap = dispatcher.pointerMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @const
|
|
||||||
* @type {Object.<string, function(goog.events.BrowserEvent)>}
|
|
||||||
*/
|
|
||||||
this.mapping_ = {
|
|
||||||
'mousedown': this.mousedown,
|
'mousedown': this.mousedown,
|
||||||
'mousemove': this.mousemove,
|
'mousemove': this.mousemove,
|
||||||
'mouseup': this.mouseup,
|
'mouseup': this.mouseup,
|
||||||
'mouseover': this.mouseover,
|
'mouseover': this.mouseover,
|
||||||
'mouseout': this.mouseout
|
'mouseout': this.mouseout
|
||||||
};
|
};
|
||||||
|
goog.base(this, dispatcher, mapping);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {goog.structs.Map}
|
||||||
|
*/
|
||||||
|
this.pointerMap = dispatcher.pointerMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
@@ -94,18 +87,6 @@ ol.pointer.MouseSource.POINTER_TYPE = 'mouse';
|
|||||||
ol.pointer.MouseSource.DEDUP_DIST = 25;
|
ol.pointer.MouseSource.DEDUP_DIST = 25;
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.MouseSource.prototype.getEvents = function() {
|
|
||||||
return goog.object.getKeys(this.mapping_);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.MouseSource.prototype.getMapping = function() {
|
|
||||||
return this.mapping_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect if a mouse event was simulated from a touch by
|
* Detect if a mouse event was simulated from a touch by
|
||||||
* checking if previously there was a touch event at the
|
* checking if previously there was a touch event at the
|
||||||
|
|||||||
@@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
goog.provide('ol.pointer.MsSource');
|
goog.provide('ol.pointer.MsSource');
|
||||||
|
|
||||||
goog.require('goog.object');
|
|
||||||
goog.require('ol.pointer.EventSource');
|
goog.require('ol.pointer.EventSource');
|
||||||
|
|
||||||
|
|
||||||
@@ -41,20 +40,7 @@ goog.require('ol.pointer.EventSource');
|
|||||||
* @extends {ol.pointer.EventSource}
|
* @extends {ol.pointer.EventSource}
|
||||||
*/
|
*/
|
||||||
ol.pointer.MsSource = function(dispatcher) {
|
ol.pointer.MsSource = function(dispatcher) {
|
||||||
goog.base(this, dispatcher);
|
var mapping = {
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {goog.structs.Map}
|
|
||||||
*/
|
|
||||||
this.pointerMap = dispatcher.pointerMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @const
|
|
||||||
* @type {Object.<string, function(goog.events.BrowserEvent)>}
|
|
||||||
*/
|
|
||||||
this.mapping_ = {
|
|
||||||
'MSPointerDown': this.msPointerDown,
|
'MSPointerDown': this.msPointerDown,
|
||||||
'MSPointerMove': this.msPointerMove,
|
'MSPointerMove': this.msPointerMove,
|
||||||
'MSPointerUp': this.msPointerUp,
|
'MSPointerUp': this.msPointerUp,
|
||||||
@@ -64,6 +50,13 @@ ol.pointer.MsSource = function(dispatcher) {
|
|||||||
'MSGotPointerCapture': this.msGotPointerCapture,
|
'MSGotPointerCapture': this.msGotPointerCapture,
|
||||||
'MSLostPointerCapture': this.msLostPointerCapture
|
'MSLostPointerCapture': this.msLostPointerCapture
|
||||||
};
|
};
|
||||||
|
goog.base(this, dispatcher, mapping);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {goog.structs.Map}
|
||||||
|
*/
|
||||||
|
this.pointerMap = dispatcher.pointerMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
@@ -80,18 +73,6 @@ ol.pointer.MsSource = function(dispatcher) {
|
|||||||
goog.inherits(ol.pointer.MsSource, ol.pointer.EventSource);
|
goog.inherits(ol.pointer.MsSource, ol.pointer.EventSource);
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.MsSource.prototype.getEvents = function() {
|
|
||||||
return goog.object.getKeys(this.mapping_);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.MsSource.prototype.getMapping = function() {
|
|
||||||
return this.mapping_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a copy of the original event that will be used
|
* Creates a copy of the original event that will be used
|
||||||
* for the fake pointer event.
|
* for the fake pointer event.
|
||||||
|
|||||||
@@ -41,20 +41,7 @@ goog.require('ol.pointer.EventSource');
|
|||||||
* @extends {ol.pointer.EventSource}
|
* @extends {ol.pointer.EventSource}
|
||||||
*/
|
*/
|
||||||
ol.pointer.NativeSource = function(dispatcher) {
|
ol.pointer.NativeSource = function(dispatcher) {
|
||||||
goog.base(this, dispatcher);
|
var mapping = {
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @type {goog.structs.Map}
|
|
||||||
*/
|
|
||||||
this.pointerMap = dispatcher.pointerMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @const
|
|
||||||
* @type {Object.<string, function(goog.events.BrowserEvent)>}
|
|
||||||
*/
|
|
||||||
this.mapping_ = {
|
|
||||||
'pointerdown': this.pointerDown,
|
'pointerdown': this.pointerDown,
|
||||||
'pointermove': this.pointerMove,
|
'pointermove': this.pointerMove,
|
||||||
'pointerup': this.pointerUp,
|
'pointerup': this.pointerUp,
|
||||||
@@ -64,22 +51,18 @@ ol.pointer.NativeSource = function(dispatcher) {
|
|||||||
'gotpointercapture': this.gotPointerCapture,
|
'gotpointercapture': this.gotPointerCapture,
|
||||||
'lostpointercapture': this.lostPointerCapture
|
'lostpointercapture': this.lostPointerCapture
|
||||||
};
|
};
|
||||||
|
goog.base(this, dispatcher, mapping);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @const
|
||||||
|
* @type {goog.structs.Map}
|
||||||
|
*/
|
||||||
|
this.pointerMap = dispatcher.pointerMap;
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.pointer.NativeSource, ol.pointer.EventSource);
|
goog.inherits(ol.pointer.NativeSource, ol.pointer.EventSource);
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.NativeSource.prototype.getEvents = function() {
|
|
||||||
return goog.object.getKeys(this.mapping_);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.NativeSource.prototype.getMapping = function() {
|
|
||||||
return this.mapping_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handler for `pointerdown`.
|
* Handler for `pointerdown`.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -32,7 +32,6 @@ goog.provide('ol.pointer.TouchSource');
|
|||||||
|
|
||||||
goog.require('goog.array');
|
goog.require('goog.array');
|
||||||
goog.require('goog.math.Coordinate');
|
goog.require('goog.math.Coordinate');
|
||||||
goog.require('goog.object');
|
|
||||||
goog.require('ol.pointer.EventSource');
|
goog.require('ol.pointer.EventSource');
|
||||||
|
|
||||||
|
|
||||||
@@ -44,7 +43,13 @@ goog.require('ol.pointer.EventSource');
|
|||||||
* @extends {ol.pointer.EventSource}
|
* @extends {ol.pointer.EventSource}
|
||||||
*/
|
*/
|
||||||
ol.pointer.TouchSource = function(dispatcher, mouseSource) {
|
ol.pointer.TouchSource = function(dispatcher, mouseSource) {
|
||||||
goog.base(this, dispatcher);
|
var mapping = {
|
||||||
|
'touchstart': this.touchstart,
|
||||||
|
'touchmove': this.touchmove,
|
||||||
|
'touchend': this.touchend,
|
||||||
|
'touchcancel': this.touchcancel
|
||||||
|
};
|
||||||
|
goog.base(this, dispatcher, mapping);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @const
|
* @const
|
||||||
@@ -89,18 +94,6 @@ ol.pointer.TouchSource = function(dispatcher, mouseSource) {
|
|||||||
* @type {?number}
|
* @type {?number}
|
||||||
*/
|
*/
|
||||||
this.resetId_ = null;
|
this.resetId_ = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @const
|
|
||||||
* @type {Object.<string, function(goog.events.BrowserEvent)>}
|
|
||||||
*/
|
|
||||||
this.mapping_ = {
|
|
||||||
'touchstart': this.touchstart,
|
|
||||||
'touchmove': this.touchmove,
|
|
||||||
'touchend': this.touchend,
|
|
||||||
'touchcancel': this.touchcancel
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.pointer.TouchSource, ol.pointer.EventSource);
|
goog.inherits(ol.pointer.TouchSource, ol.pointer.EventSource);
|
||||||
|
|
||||||
@@ -112,18 +105,6 @@ goog.inherits(ol.pointer.TouchSource, ol.pointer.EventSource);
|
|||||||
ol.pointer.TouchSource.POINTER_TYPE = 'touch';
|
ol.pointer.TouchSource.POINTER_TYPE = 'touch';
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.TouchSource.prototype.getEvents = function() {
|
|
||||||
return goog.object.getKeys(this.mapping_);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** @inheritDoc */
|
|
||||||
ol.pointer.TouchSource.prototype.getMapping = function() {
|
|
||||||
return this.mapping_;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @param {Touch} inTouch
|
* @param {Touch} inTouch
|
||||||
|
|||||||
Reference in New Issue
Block a user