diff --git a/src/ol/interaction/dragboxinteraction.js b/src/ol/interaction/dragboxinteraction.js index 63a24d3eaf..0e7c4accad 100644 --- a/src/ol/interaction/dragboxinteraction.js +++ b/src/ol/interaction/dragboxinteraction.js @@ -109,19 +109,15 @@ goog.inherits(ol.interaction.DragBox, ol.interaction.PointerInteraction); /** * Returns true if the pointer event is generated by a mouse pointer. - * @param {ol.MapBrowserEvent} mapBrowserEvent + * @param {ol.MapBrowserPointerEvent} mapBrowserEvent * @return {boolean} */ ol.interaction.DragBox.prototype.isMousePointer = function(mapBrowserEvent) { - goog.asserts.assertInstanceof(mapBrowserEvent, ol.MapBrowserPointerEvent); - var mapBrowserPointerEvent = - /** @type {ol.MapBrowserPointerEvent} */ (mapBrowserEvent); - /* pointerId must be 1 for mouse devices, * see: http://www.w3.org/Submission/pointer-events/#pointerevent-interface */ - return mapBrowserPointerEvent.pointerEvent.pointerId == 1; + return mapBrowserEvent.pointerEvent.pointerId == 1; }; diff --git a/src/ol/interaction/pointerinteraction.js b/src/ol/interaction/pointerinteraction.js index 98d95453d1..40afae7a40 100644 --- a/src/ol/interaction/pointerinteraction.js +++ b/src/ol/interaction/pointerinteraction.js @@ -5,6 +5,7 @@ goog.require('goog.functions'); goog.require('goog.object'); goog.require('ol.MapBrowserEvent'); goog.require('ol.MapBrowserEvent.EventType'); +goog.require('ol.MapBrowserPointerEvent'); goog.require('ol.Pixel'); goog.require('ol.ViewHint'); 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 * or pointerup event. * @private @@ -74,7 +75,7 @@ ol.interaction.PointerInteraction.isTouchEvent_ = function(mapBrowserEvent) { /** - * @param {ol.MapBrowserEvent} mapBrowserEvent Event. + * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @private */ 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 */ 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 * @return {boolean} Capture dragging. */ @@ -114,7 +115,7 @@ ol.interaction.PointerInteraction.prototype.handlePointerUp = /** - * @param {ol.MapBrowserEvent} mapBrowserEvent Event. + * @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event. * @protected * @return {boolean} Capture dragging. */ @@ -127,20 +128,26 @@ ol.interaction.PointerInteraction.prototype.handlePointerDown = */ ol.interaction.PointerInteraction.prototype.handleMapBrowserEvent = function(mapBrowserEvent) { + goog.asserts.assertInstanceof(mapBrowserEvent, ol.MapBrowserPointerEvent); + var mapBrowserPointerEvent = + /** @type {ol.MapBrowserPointerEvent} */ (mapBrowserEvent); + var view = mapBrowserEvent.map.getView(); - this.updateTrackedTouches_(mapBrowserEvent); + this.updateTrackedTouches_(mapBrowserPointerEvent); if (this.handled_) { - if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDRAG) { + if (mapBrowserPointerEvent.type == + ol.MapBrowserEvent.EventType.POINTERDRAG) { this.handlePointerDrag(mapBrowserEvent); - } else if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERUP) { - this.handled_ = this.handlePointerUp(mapBrowserEvent); + } else if (mapBrowserPointerEvent.type == + ol.MapBrowserEvent.EventType.POINTERUP) { + this.handled_ = this.handlePointerUp(mapBrowserPointerEvent); if (!this.handled_) { view.setHint(ol.ViewHint.INTERACTING, -1); } } } - if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDOWN) { - var handled = this.handlePointerDown(mapBrowserEvent); + if (mapBrowserPointerEvent.type == ol.MapBrowserEvent.EventType.POINTERDOWN) { + var handled = this.handlePointerDown(mapBrowserPointerEvent); if (!this.handled_ && handled) { view.setHint(ol.ViewHint.INTERACTING, 1); } diff --git a/src/ol/mapbrowserevent.js b/src/ol/mapbrowserevent.js index a953498668..5c94b1d975 100644 --- a/src/ol/mapbrowserevent.js +++ b/src/ol/mapbrowserevent.js @@ -1,6 +1,7 @@ goog.provide('ol.MapBrowserEvent'); goog.provide('ol.MapBrowserEvent.EventType'); goog.provide('ol.MapBrowserEventHandler'); +goog.provide('ol.MapBrowserPointerEvent'); goog.require('goog.array'); goog.require('goog.asserts');