Merge pull request #1881 from fredj/pointerevents-cleanups

Miscellaneous pointer events cleanups
This commit is contained in:
Frédéric Junod
2014-03-20 16:36:35 +01:00
4 changed files with 19 additions and 31 deletions
+4 -8
View File
@@ -101,8 +101,7 @@ ol.interaction.Pointer.prototype.updateTrackedPointers_ =
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @protected * @protected
*/ */
ol.interaction.Pointer.prototype.handlePointerDrag = ol.interaction.Pointer.prototype.handlePointerDrag = goog.nullFunction;
goog.nullFunction;
/** /**
@@ -110,8 +109,7 @@ ol.interaction.Pointer.prototype.handlePointerDrag =
* @protected * @protected
* @return {boolean} Capture dragging. * @return {boolean} Capture dragging.
*/ */
ol.interaction.Pointer.prototype.handlePointerUp = ol.interaction.Pointer.prototype.handlePointerUp = goog.functions.FALSE;
goog.functions.FALSE;
/** /**
@@ -119,8 +117,7 @@ ol.interaction.Pointer.prototype.handlePointerUp =
* @protected * @protected
* @return {boolean} Capture dragging. * @return {boolean} Capture dragging.
*/ */
ol.interaction.Pointer.prototype.handlePointerDown = ol.interaction.Pointer.prototype.handlePointerDown = goog.functions.FALSE;
goog.functions.FALSE;
/** /**
@@ -162,5 +159,4 @@ ol.interaction.Pointer.prototype.handleMapBrowserEvent =
* @param {boolean} handled Was the event handled by the interaction? * @param {boolean} handled Was the event handled by the interaction?
* @return {boolean} Should the event be stopped? * @return {boolean} Should the event be stopped?
*/ */
ol.interaction.Pointer.prototype.shouldStopEvent = ol.interaction.Pointer.prototype.shouldStopEvent = goog.functions.FALSE;
goog.functions.FALSE;
+2 -2
View File
@@ -58,7 +58,7 @@ ol.pointer.MouseSource = function(dispatcher) {
/** /**
* @const * @const
* @type {Array.<goog.math.Coordinate>} * @type {Array.<ol.Pixel>}
*/ */
this.lastTouches = []; this.lastTouches = [];
}; };
@@ -118,7 +118,7 @@ ol.pointer.MouseSource.prototype.isEventSimulatedFromTouch_ =
var x = inEvent.clientX, y = inEvent.clientY; var x = inEvent.clientX, y = inEvent.clientY;
for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) { for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
// simulated mouse events will be swallowed near a primary touchend // simulated mouse events will be swallowed near a primary touchend
var dx = Math.abs(x - t.x), dy = Math.abs(y - t.y); var dx = Math.abs(x - t[0]), dy = Math.abs(y - t[1]);
if (dx <= ol.pointer.MouseSource.DEDUP_DIST && if (dx <= ol.pointer.MouseSource.DEDUP_DIST &&
dy <= ol.pointer.MouseSource.DEDUP_DIST) { dy <= ol.pointer.MouseSource.DEDUP_DIST) {
return true; return true;
-6
View File
@@ -59,12 +59,6 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) {
*/ */
this.browserEvent = browserEvent; this.browserEvent = browserEvent;
/**
* @const
* @type {Event}
*/
this.originalEvent = browserEvent.getBrowserEvent();
var eventDict = goog.isDef(opt_eventDict) ? opt_eventDict : {}; var eventDict = goog.isDef(opt_eventDict) ? opt_eventDict : {};
/** /**
+13 -15
View File
@@ -31,7 +31,6 @@
goog.provide('ol.pointer.TouchSource'); goog.provide('ol.pointer.TouchSource');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.math.Coordinate');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.pointer.EventSource'); goog.require('ol.pointer.EventSource');
goog.require('ol.pointer.MouseSource'); goog.require('ol.pointer.MouseSource');
@@ -82,15 +81,6 @@ ol.pointer.TouchSource = function(dispatcher, mouseSource) {
* @type {number|undefined} * @type {number|undefined}
*/ */
this.resetId_ = undefined; this.resetId_ = undefined;
/**
* @private
* @type {function()}
*/
this.resetClickCountHandler_ = goog.bind(function() {
this.clickCount_ = 0;
this.resetId_ = undefined;
}, this);
}; };
goog.inherits(ol.pointer.TouchSource, ol.pointer.EventSource); goog.inherits(ol.pointer.TouchSource, ol.pointer.EventSource);
@@ -134,10 +124,9 @@ ol.pointer.TouchSource.prototype.isPrimaryTouch_ = function(inTouch) {
* @private * @private
*/ */
ol.pointer.TouchSource.prototype.setPrimaryTouch_ = function(inTouch) { ol.pointer.TouchSource.prototype.setPrimaryTouch_ = function(inTouch) {
if (goog.object.getCount(this.pointerMap) === 0 || var count = goog.object.getCount(this.pointerMap);
(goog.object.getCount(this.pointerMap) === 1 && if (count === 0 || (count === 1 && goog.object.containsKey(this.pointerMap,
goog.object.containsKey(this.pointerMap, ol.pointer.MouseSource.POINTER_ID.toString()))) {
ol.pointer.MouseSource.POINTER_ID.toString()))) {
this.firstTouchId_ = inTouch.identifier; this.firstTouchId_ = inTouch.identifier;
this.cancelResetClickCount_(); this.cancelResetClickCount_();
} }
@@ -165,6 +154,15 @@ ol.pointer.TouchSource.prototype.resetClickCount_ = function() {
}; };
/**
* @private
*/
ol.pointer.TouchSource.prototype.resetClickCountHandler_ = function() {
this.clickCount_ = 0;
this.resetId_ = undefined;
};
/** /**
* @private * @private
*/ */
@@ -434,7 +432,7 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
// only the primary finger will synth mouse events // only the primary finger will synth mouse events
if (this.isPrimaryTouch_(t)) { if (this.isPrimaryTouch_(t)) {
// remember x/y of last touch // remember x/y of last touch
var lt = new goog.math.Coordinate(t.clientX, t.clientY); var lt = /** @type {ol.Pixel} */ ([t.clientX, t.clientY]);
lts.push(lt); lts.push(lt);
goog.global.setTimeout(function() { goog.global.setTimeout(function() {