base dragrotateinteraction on pointer interaction

This commit is contained in:
tsauerwein
2014-02-26 14:43:34 +01:00
parent 12b0fee790
commit c593add6d8
3 changed files with 43 additions and 23 deletions
+5 -18
View File
@@ -63,7 +63,8 @@ goog.inherits(ol.DragBoxEvent, goog.events.Event);
/**
* Allows the user to zoom the map by clicking and dragging on the map,
* when the shift key is held down.
* normally combined with an {@link ol.events.condition} that limits
* it to when the shift key is held down.
*
* This interaction is only supported for mouse devices.
*
@@ -107,25 +108,11 @@ ol.interaction.DragBox = function(opt_options) {
goog.inherits(ol.interaction.DragBox, ol.interaction.PointerInteraction);
/**
* Returns true if the pointer event is generated by a mouse pointer.
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent
* @return {boolean}
*/
ol.interaction.DragBox.prototype.isMousePointer =
function(mapBrowserEvent) {
/* pointerId must be 1 for mouse devices,
* see: http://www.w3.org/Submission/pointer-events/#pointerevent-interface
*/
return mapBrowserEvent.pointerEvent.pointerId == 1;
};
/**
* @inheritDoc
*/
ol.interaction.DragBox.prototype.handlePointerDrag = function(mapBrowserEvent) {
if (!this.isMousePointer(mapBrowserEvent)) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
return;
}
@@ -154,7 +141,7 @@ ol.interaction.DragBox.prototype.onBoxEnd = goog.nullFunction;
*/
ol.interaction.DragBox.prototype.handlePointerUp =
function(mapBrowserEvent) {
if (!this.isMousePointer(mapBrowserEvent)) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
return false;
}
@@ -177,7 +164,7 @@ ol.interaction.DragBox.prototype.handlePointerUp =
*/
ol.interaction.DragBox.prototype.handlePointerDown =
function(mapBrowserEvent) {
if (!this.isMousePointer(mapBrowserEvent)) {
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
return false;
}