introduce type POINTERDRAG to make a distinction between pointer move and drag

This commit is contained in:
tsauerwein
2014-02-19 17:45:03 +01:00
parent eca6846dac
commit 692a68644f
5 changed files with 26 additions and 22 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ goog.inherits(ol.interaction.Pan, ol.interaction.PointerInteraction);
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.Pan.prototype.handlePointerMove = function(mapBrowserEvent) { ol.interaction.Pan.prototype.handlePointerDrag = function(mapBrowserEvent) {
goog.asserts.assert(this.targetTouches.length >= 1); goog.asserts.assert(this.targetTouches.length >= 1);
var centroid = ol.interaction.PointerInteraction.centroid(this.targetTouches); var centroid = ol.interaction.PointerInteraction.centroid(this.targetTouches);
if (!goog.isNull(this.lastCentroid)) { if (!goog.isNull(this.lastCentroid)) {
+6 -6
View File
@@ -60,15 +60,15 @@ ol.interaction.PointerInteraction.centroid = function(touches) {
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserEvent} mapBrowserEvent Event.
* @return {boolean} Whether the event is a touchstart, touchmove * @return {boolean} Whether the event is a pointerdown, pointerdrag
* or touchend event. * or pointerup event.
* @private * @private
*/ */
ol.interaction.PointerInteraction.isTouchEvent_ = function(mapBrowserEvent) { ol.interaction.PointerInteraction.isTouchEvent_ = function(mapBrowserEvent) {
var type = mapBrowserEvent.type; var type = mapBrowserEvent.type;
return ( return (
type === ol.MapBrowserEvent.EventType.POINTERDOWN || type === ol.MapBrowserEvent.EventType.POINTERDOWN ||
type === ol.MapBrowserEvent.EventType.POINTERMOVE || type === ol.MapBrowserEvent.EventType.POINTERDRAG ||
type === ol.MapBrowserEvent.EventType.POINTERUP); type === ol.MapBrowserEvent.EventType.POINTERUP);
}; };
@@ -100,7 +100,7 @@ ol.interaction.PointerInteraction.prototype.updateTrackedTouches_ =
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserEvent} mapBrowserEvent Event.
* @protected * @protected
*/ */
ol.interaction.PointerInteraction.prototype.handlePointerMove = ol.interaction.PointerInteraction.prototype.handlePointerDrag =
goog.nullFunction; goog.nullFunction;
@@ -130,8 +130,8 @@ ol.interaction.PointerInteraction.prototype.handleMapBrowserEvent =
var view = mapBrowserEvent.map.getView(); var view = mapBrowserEvent.map.getView();
this.updateTrackedTouches_(mapBrowserEvent); this.updateTrackedTouches_(mapBrowserEvent);
if (this.handled_) { if (this.handled_) {
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) { if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDRAG) {
this.handlePointerMove(mapBrowserEvent); this.handlePointerDrag(mapBrowserEvent);
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERUP) { } else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERUP) {
this.handled_ = this.handlePointerUp(mapBrowserEvent); this.handled_ = this.handlePointerUp(mapBrowserEvent);
if (!this.handled_) { if (!this.handled_) {
+1 -1
View File
@@ -67,7 +67,7 @@ goog.inherits(ol.interaction.Rotate, ol.interaction.PointerInteraction);
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.Rotate.prototype.handlePointerMove = ol.interaction.Rotate.prototype.handlePointerDrag =
function(mapBrowserEvent) { function(mapBrowserEvent) {
goog.asserts.assert(this.targetTouches.length >= 2); goog.asserts.assert(this.targetTouches.length >= 2);
var rotationDelta = 0.0; var rotationDelta = 0.0;
+1 -1
View File
@@ -55,7 +55,7 @@ goog.inherits(ol.interaction.Zoom, ol.interaction.PointerInteraction);
/** /**
* @inheritDoc * @inheritDoc
*/ */
ol.interaction.Zoom.prototype.handlePointerMove = ol.interaction.Zoom.prototype.handlePointerDrag =
function(mapBrowserEvent) { function(mapBrowserEvent) {
goog.asserts.assert(this.targetTouches.length >= 2); goog.asserts.assert(this.targetTouches.length >= 2);
var scaleDelta = 1.0; var scaleDelta = 1.0;
+17 -13
View File
@@ -330,7 +330,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
pointerEvent.clientY != this.down_.clientY) { pointerEvent.clientY != this.down_.clientY) {
this.dragged_ = true; this.dragged_ = true;
var newEvent = new ol.MapBrowserPointerEvent( var newEvent = new ol.MapBrowserPointerEvent(
ol.MapBrowserEvent.EventType.POINTERMOVE, this.map_, pointerEvent); ol.MapBrowserEvent.EventType.POINTERDRAG, this.map_, pointerEvent);
this.dispatchEvent(newEvent); this.dispatchEvent(newEvent);
} }
@@ -371,18 +371,9 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
* @enum {string} * @enum {string}
*/ */
ol.MapBrowserEvent.EventType = { ol.MapBrowserEvent.EventType = {
CLICK: goog.events.EventType.CLICK,
DBLCLICK: goog.events.EventType.DBLCLICK,
DRAGSTART: 'dragstart',
DRAG: 'drag',
DRAGEND: 'dragend',
DOWN: 'down',
MOUSEMOVE: goog.events.EventType.MOUSEMOVE,
SINGLECLICK: 'singleclick', SINGLECLICK: 'singleclick',
TOUCHSTART: goog.events.EventType.TOUCHSTART, DBLCLICK: goog.events.EventType.DBLCLICK,
TOUCHMOVE: goog.events.EventType.TOUCHMOVE, POINTERDRAG: 'pointermove',
TOUCHEND: goog.events.EventType.TOUCHEND,
POINTERMOVE: 'pointermove', POINTERMOVE: 'pointermove',
POINTERDOWN: 'pointerdown', POINTERDOWN: 'pointerdown',
@@ -391,5 +382,18 @@ ol.MapBrowserEvent.EventType = {
POINTEROUT: 'pointerout', POINTEROUT: 'pointerout',
POINTERENTER: 'pointerenter', POINTERENTER: 'pointerenter',
POINTERLEAVE: 'pointerleave', POINTERLEAVE: 'pointerleave',
POINTERCANCEL: 'pointercancel' POINTERCANCEL: 'pointercancel',
// TODO old types that should be removed once
// the interactions are adapted
CLICK: goog.events.EventType.CLICK,
DRAGSTART: 'dragstart',
DRAG: 'drag',
DRAGEND: 'dragend',
DOWN: 'down',
MOUSEMOVE: goog.events.EventType.MOUSEMOVE,
TOUCHSTART: goog.events.EventType.TOUCHSTART,
TOUCHMOVE: goog.events.EventType.TOUCHMOVE,
TOUCHEND: goog.events.EventType.TOUCHEND
}; };