PointerInteraction uses MapBrowserPointerEvent not MapBrowserEvent

This commit is contained in:
tsauerwein
2014-02-26 11:54:28 +01:00
parent a696150470
commit fca9c50a3f
3 changed files with 21 additions and 17 deletions

View File

@@ -109,19 +109,15 @@ goog.inherits(ol.interaction.DragBox, ol.interaction.PointerInteraction);
/** /**
* Returns true if the pointer event is generated by a mouse pointer. * Returns true if the pointer event is generated by a mouse pointer.
* @param {ol.MapBrowserEvent} mapBrowserEvent * @param {ol.MapBrowserPointerEvent} mapBrowserEvent
* @return {boolean} * @return {boolean}
*/ */
ol.interaction.DragBox.prototype.isMousePointer = ol.interaction.DragBox.prototype.isMousePointer =
function(mapBrowserEvent) { function(mapBrowserEvent) {
goog.asserts.assertInstanceof(mapBrowserEvent, ol.MapBrowserPointerEvent);
var mapBrowserPointerEvent =
/** @type {ol.MapBrowserPointerEvent} */ (mapBrowserEvent);
/* pointerId must be 1 for mouse devices, /* pointerId must be 1 for mouse devices,
* see: http://www.w3.org/Submission/pointer-events/#pointerevent-interface * see: http://www.w3.org/Submission/pointer-events/#pointerevent-interface
*/ */
return mapBrowserPointerEvent.pointerEvent.pointerId == 1; return mapBrowserEvent.pointerEvent.pointerId == 1;
}; };

View File

@@ -5,6 +5,7 @@ goog.require('goog.functions');
goog.require('goog.object'); goog.require('goog.object');
goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent');
goog.require('ol.MapBrowserEvent.EventType'); goog.require('ol.MapBrowserEvent.EventType');
goog.require('ol.MapBrowserPointerEvent');
goog.require('ol.Pixel'); goog.require('ol.Pixel');
goog.require('ol.ViewHint'); goog.require('ol.ViewHint');
goog.require('ol.interaction.Interaction'); goog.require('ol.interaction.Interaction');
@@ -59,7 +60,7 @@ ol.interaction.PointerInteraction.centroid = function(touches) {
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @return {boolean} Whether the event is a pointerdown, pointerdrag * @return {boolean} Whether the event is a pointerdown, pointerdrag
* or pointerup event. * or pointerup event.
* @private * @private
@@ -74,7 +75,7 @@ ol.interaction.PointerInteraction.isTouchEvent_ = function(mapBrowserEvent) {
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @private * @private
*/ */
ol.interaction.PointerInteraction.prototype.updateTrackedTouches_ = ol.interaction.PointerInteraction.prototype.updateTrackedTouches_ =
@@ -97,7 +98,7 @@ ol.interaction.PointerInteraction.prototype.updateTrackedTouches_ =
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @protected * @protected
*/ */
ol.interaction.PointerInteraction.prototype.handlePointerDrag = ol.interaction.PointerInteraction.prototype.handlePointerDrag =
@@ -105,7 +106,7 @@ ol.interaction.PointerInteraction.prototype.handlePointerDrag =
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @protected * @protected
* @return {boolean} Capture dragging. * @return {boolean} Capture dragging.
*/ */
@@ -114,7 +115,7 @@ ol.interaction.PointerInteraction.prototype.handlePointerUp =
/** /**
* @param {ol.MapBrowserEvent} mapBrowserEvent Event. * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
* @protected * @protected
* @return {boolean} Capture dragging. * @return {boolean} Capture dragging.
*/ */
@@ -127,20 +128,26 @@ ol.interaction.PointerInteraction.prototype.handlePointerDown =
*/ */
ol.interaction.PointerInteraction.prototype.handleMapBrowserEvent = ol.interaction.PointerInteraction.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) { function(mapBrowserEvent) {
goog.asserts.assertInstanceof(mapBrowserEvent, ol.MapBrowserPointerEvent);
var mapBrowserPointerEvent =
/** @type {ol.MapBrowserPointerEvent} */ (mapBrowserEvent);
var view = mapBrowserEvent.map.getView(); var view = mapBrowserEvent.map.getView();
this.updateTrackedTouches_(mapBrowserEvent); this.updateTrackedTouches_(mapBrowserPointerEvent);
if (this.handled_) { if (this.handled_) {
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDRAG) { if (mapBrowserPointerEvent.type ==
ol.MapBrowserEvent.EventType.POINTERDRAG) {
this.handlePointerDrag(mapBrowserEvent); this.handlePointerDrag(mapBrowserEvent);
} else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERUP) { } else if (mapBrowserPointerEvent.type ==
this.handled_ = this.handlePointerUp(mapBrowserEvent); ol.MapBrowserEvent.EventType.POINTERUP) {
this.handled_ = this.handlePointerUp(mapBrowserPointerEvent);
if (!this.handled_) { if (!this.handled_) {
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
} }
} }
} }
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDOWN) { if (mapBrowserPointerEvent.type == ol.MapBrowserEvent.EventType.POINTERDOWN) {
var handled = this.handlePointerDown(mapBrowserEvent); var handled = this.handlePointerDown(mapBrowserPointerEvent);
if (!this.handled_ && handled) { if (!this.handled_ && handled) {
view.setHint(ol.ViewHint.INTERACTING, 1); view.setHint(ol.ViewHint.INTERACTING, 1);
} }

View File

@@ -1,6 +1,7 @@
goog.provide('ol.MapBrowserEvent'); goog.provide('ol.MapBrowserEvent');
goog.provide('ol.MapBrowserEvent.EventType'); goog.provide('ol.MapBrowserEvent.EventType');
goog.provide('ol.MapBrowserEventHandler'); goog.provide('ol.MapBrowserEventHandler');
goog.provide('ol.MapBrowserPointerEvent');
goog.require('goog.array'); goog.require('goog.array');
goog.require('goog.asserts'); goog.require('goog.asserts');