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

View File

@@ -55,7 +55,7 @@ goog.inherits(ol.interaction.Pan, ol.interaction.PointerInteraction);
/**
* @inheritDoc
*/
ol.interaction.Pan.prototype.handlePointerMove = function(mapBrowserEvent) {
ol.interaction.Pan.prototype.handlePointerDrag = function(mapBrowserEvent) {
goog.asserts.assert(this.targetTouches.length >= 1);
var centroid = ol.interaction.PointerInteraction.centroid(this.targetTouches);
if (!goog.isNull(this.lastCentroid)) {

View File

@@ -60,15 +60,15 @@ ol.interaction.PointerInteraction.centroid = function(touches) {
/**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
* @return {boolean} Whether the event is a touchstart, touchmove
* or touchend event.
* @return {boolean} Whether the event is a pointerdown, pointerdrag
* or pointerup event.
* @private
*/
ol.interaction.PointerInteraction.isTouchEvent_ = function(mapBrowserEvent) {
var type = mapBrowserEvent.type;
return (
type === ol.MapBrowserEvent.EventType.POINTERDOWN ||
type === ol.MapBrowserEvent.EventType.POINTERMOVE ||
type === ol.MapBrowserEvent.EventType.POINTERDRAG ||
type === ol.MapBrowserEvent.EventType.POINTERUP);
};
@@ -100,7 +100,7 @@ ol.interaction.PointerInteraction.prototype.updateTrackedTouches_ =
* @param {ol.MapBrowserEvent} mapBrowserEvent Event.
* @protected
*/
ol.interaction.PointerInteraction.prototype.handlePointerMove =
ol.interaction.PointerInteraction.prototype.handlePointerDrag =
goog.nullFunction;
@@ -130,8 +130,8 @@ ol.interaction.PointerInteraction.prototype.handleMapBrowserEvent =
var view = mapBrowserEvent.map.getView();
this.updateTrackedTouches_(mapBrowserEvent);
if (this.handled_) {
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERMOVE) {
this.handlePointerMove(mapBrowserEvent);
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDRAG) {
this.handlePointerDrag(mapBrowserEvent);
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERUP) {
this.handled_ = this.handlePointerUp(mapBrowserEvent);
if (!this.handled_) {

View File

@@ -67,7 +67,7 @@ goog.inherits(ol.interaction.Rotate, ol.interaction.PointerInteraction);
/**
* @inheritDoc
*/
ol.interaction.Rotate.prototype.handlePointerMove =
ol.interaction.Rotate.prototype.handlePointerDrag =
function(mapBrowserEvent) {
goog.asserts.assert(this.targetTouches.length >= 2);
var rotationDelta = 0.0;

View File

@@ -55,7 +55,7 @@ goog.inherits(ol.interaction.Zoom, ol.interaction.PointerInteraction);
/**
* @inheritDoc
*/
ol.interaction.Zoom.prototype.handlePointerMove =
ol.interaction.Zoom.prototype.handlePointerDrag =
function(mapBrowserEvent) {
goog.asserts.assert(this.targetTouches.length >= 2);
var scaleDelta = 1.0;

View File

@@ -330,7 +330,7 @@ ol.MapBrowserEventHandler.prototype.handlePointerMove_ =
pointerEvent.clientY != this.down_.clientY) {
this.dragged_ = true;
var newEvent = new ol.MapBrowserPointerEvent(
ol.MapBrowserEvent.EventType.POINTERMOVE, this.map_, pointerEvent);
ol.MapBrowserEvent.EventType.POINTERDRAG, this.map_, pointerEvent);
this.dispatchEvent(newEvent);
}
@@ -371,18 +371,9 @@ ol.MapBrowserEventHandler.prototype.disposeInternal = function() {
* @enum {string}
*/
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',
TOUCHSTART: goog.events.EventType.TOUCHSTART,
TOUCHMOVE: goog.events.EventType.TOUCHMOVE,
TOUCHEND: goog.events.EventType.TOUCHEND,
DBLCLICK: goog.events.EventType.DBLCLICK,
POINTERDRAG: 'pointermove',
POINTERMOVE: 'pointermove',
POINTERDOWN: 'pointerdown',
@@ -391,5 +382,18 @@ ol.MapBrowserEvent.EventType = {
POINTEROUT: 'pointerout',
POINTERENTER: 'pointerenter',
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
};