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

View File

@@ -101,8 +101,7 @@ ol.interaction.Pointer.prototype.updateTrackedPointers_ =
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @protected
*/
ol.interaction.Pointer.prototype.handlePointerDrag =
goog.nullFunction;
ol.interaction.Pointer.prototype.handlePointerDrag = goog.nullFunction;
/**
@@ -110,8 +109,7 @@ ol.interaction.Pointer.prototype.handlePointerDrag =
* @protected
* @return {boolean} Capture dragging.
*/
ol.interaction.Pointer.prototype.handlePointerUp =
goog.functions.FALSE;
ol.interaction.Pointer.prototype.handlePointerUp = goog.functions.FALSE;
/**
@@ -119,8 +117,7 @@ ol.interaction.Pointer.prototype.handlePointerUp =
* @protected
* @return {boolean} Capture dragging.
*/
ol.interaction.Pointer.prototype.handlePointerDown =
goog.functions.FALSE;
ol.interaction.Pointer.prototype.handlePointerDown = goog.functions.FALSE;
/**
@@ -162,5 +159,4 @@ ol.interaction.Pointer.prototype.handleMapBrowserEvent =
* @param {boolean} handled Was the event handled by the interaction?
* @return {boolean} Should the event be stopped?
*/
ol.interaction.Pointer.prototype.shouldStopEvent =
goog.functions.FALSE;
ol.interaction.Pointer.prototype.shouldStopEvent = goog.functions.FALSE;

View File

@@ -58,7 +58,7 @@ ol.pointer.MouseSource = function(dispatcher) {
/**
* @const
* @type {Array.<goog.math.Coordinate>}
* @type {Array.<ol.Pixel>}
*/
this.lastTouches = [];
};
@@ -118,7 +118,7 @@ ol.pointer.MouseSource.prototype.isEventSimulatedFromTouch_ =
var x = inEvent.clientX, y = inEvent.clientY;
for (var i = 0, l = lts.length, t; i < l && (t = lts[i]); i++) {
// 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 &&
dy <= ol.pointer.MouseSource.DEDUP_DIST) {
return true;

View File

@@ -59,12 +59,6 @@ ol.pointer.PointerEvent = function(type, browserEvent, opt_eventDict) {
*/
this.browserEvent = browserEvent;
/**
* @const
* @type {Event}
*/
this.originalEvent = browserEvent.getBrowserEvent();
var eventDict = goog.isDef(opt_eventDict) ? opt_eventDict : {};
/**

View File

@@ -31,7 +31,6 @@
goog.provide('ol.pointer.TouchSource');
goog.require('goog.array');
goog.require('goog.math.Coordinate');
goog.require('goog.object');
goog.require('ol.pointer.EventSource');
goog.require('ol.pointer.MouseSource');
@@ -82,15 +81,6 @@ ol.pointer.TouchSource = function(dispatcher, mouseSource) {
* @type {number|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);
@@ -134,10 +124,9 @@ ol.pointer.TouchSource.prototype.isPrimaryTouch_ = function(inTouch) {
* @private
*/
ol.pointer.TouchSource.prototype.setPrimaryTouch_ = function(inTouch) {
if (goog.object.getCount(this.pointerMap) === 0 ||
(goog.object.getCount(this.pointerMap) === 1 &&
goog.object.containsKey(this.pointerMap,
ol.pointer.MouseSource.POINTER_ID.toString()))) {
var count = goog.object.getCount(this.pointerMap);
if (count === 0 || (count === 1 && goog.object.containsKey(this.pointerMap,
ol.pointer.MouseSource.POINTER_ID.toString()))) {
this.firstTouchId_ = inTouch.identifier;
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
*/
@@ -434,7 +432,7 @@ ol.pointer.TouchSource.prototype.dedupSynthMouse_ = function(inEvent) {
// only the primary finger will synth mouse events
if (this.isPrimaryTouch_(t)) {
// 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);
goog.global.setTimeout(function() {