Add handle*Event options to ol.interaction.Pointer
More specifically: handleDownEvent, handleDragEvent, handleMoveEvent, and handleUpEvent.
This commit is contained in:
@@ -2430,23 +2430,64 @@ olx.interaction.PinchZoomOptions.prototype.duration;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{handleEvent: function(ol.MapBrowserEvent):boolean}}
|
||||
* @typedef {{handleDownEvent: (function(ol.MapBrowserPointerEvent):boolean|undefined),
|
||||
* handleDragEvent: (function(ol.MapBrowserPointerEvent)|undefined),
|
||||
* handleEvent: (function(ol.MapBrowserEvent):boolean|undefined),
|
||||
* handleMoveEvent: (function(ol.MapBrowserPointerEvent)|undefined),
|
||||
* handleUpEvent: (function(ol.MapBrowserPointerEvent):boolean|undefined)}}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions;
|
||||
|
||||
|
||||
/**
|
||||
* Function handling "down" events. If the function returns `true` then a drag
|
||||
* sequence is started.
|
||||
* @type {(function(ol.MapBrowserPointerEvent):boolean|undefined)}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions.prototype.handleDownEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Function handling "drag" events. This function is called on "move" events
|
||||
* during a drag sequence.
|
||||
* @type {(function(ol.MapBrowserPointerEvent):boolean|undefined)}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions.prototype.handleDragEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Method called by the map to notify the interaction that a browser event was
|
||||
* dispatched to the map. The function may return `false` to prevent the
|
||||
* propagation of the event to other interactions in the map's interactions
|
||||
* chain.
|
||||
* @type {function(ol.MapBrowserEvent):boolean}
|
||||
* @type {(function(ol.MapBrowserEvent):boolean|undefined)}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions.prototype.handleEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Function handling "move" events. This function is called on "move" events,
|
||||
* also during a drag sequence (so during a drag sequence both the
|
||||
* `handleDragEvent` function and this function are called).
|
||||
* @type {(function(ol.MapBrowserPointerEvent):boolean|undefined)}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions.prototype.handleMoveEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Function handling "up" events. If the function returns `false` then the
|
||||
* current drag sequence is stopped.
|
||||
* @type {(function(ol.MapBrowserPointerEvent):boolean|undefined)}
|
||||
* @api
|
||||
*/
|
||||
olx.interaction.PointerOptions.prototype.handleUpEvent;
|
||||
|
||||
|
||||
/**
|
||||
* @typedef {{addCondition: (ol.events.ConditionType|undefined),
|
||||
* condition: (ol.events.ConditionType|undefined),
|
||||
|
||||
@@ -86,7 +86,11 @@ goog.inherits(ol.DragBoxEvent, goog.events.Event);
|
||||
*/
|
||||
ol.interaction.DragBox = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleDownEvent: ol.interaction.DragBox.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.DragBox.handleDragEvent_,
|
||||
handleUpEvent: ol.interaction.DragBox.handleUpEvent_
|
||||
});
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
@@ -120,9 +124,11 @@ goog.inherits(ol.interaction.DragBox, ol.interaction.Pointer);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragBox}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragBox.prototype.handlePointerDrag = function(mapBrowserEvent) {
|
||||
ol.interaction.DragBox.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return;
|
||||
}
|
||||
@@ -143,6 +149,7 @@ ol.interaction.DragBox.prototype.getGeometry = function() {
|
||||
|
||||
/**
|
||||
* To be overriden by child classes.
|
||||
* FIXME: use constructor option instead of relying on overridding.
|
||||
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
|
||||
* @protected
|
||||
*/
|
||||
@@ -150,9 +157,12 @@ ol.interaction.DragBox.prototype.onBoxEnd = goog.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.DragBox}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragBox.prototype.handlePointerUp = function(mapBrowserEvent) {
|
||||
ol.interaction.DragBox.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
@@ -173,9 +183,12 @@ ol.interaction.DragBox.prototype.handlePointerUp = function(mapBrowserEvent) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.DragBox}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragBox.prototype.handlePointerDown = function(mapBrowserEvent) {
|
||||
ol.interaction.DragBox.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,11 @@ goog.require('ol.interaction.Pointer');
|
||||
*/
|
||||
ol.interaction.DragPan = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleDownEvent: ol.interaction.DragPan.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.DragPan.handleDragEvent_,
|
||||
handleUpEvent: ol.interaction.DragPan.handleUpEvent_
|
||||
});
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
@@ -61,9 +65,11 @@ goog.inherits(ol.interaction.DragPan, ol.interaction.Pointer);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragPan}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragPan.prototype.handlePointerDrag = function(mapBrowserEvent) {
|
||||
ol.interaction.DragPan.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
goog.asserts.assert(this.targetPointers.length >= 1);
|
||||
var centroid =
|
||||
ol.interaction.Pointer.centroid(this.targetPointers);
|
||||
@@ -89,9 +95,12 @@ ol.interaction.DragPan.prototype.handlePointerDrag = function(mapBrowserEvent) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.DragPan}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragPan.prototype.handlePointerUp = function(mapBrowserEvent) {
|
||||
ol.interaction.DragPan.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
if (this.targetPointers.length === 0) {
|
||||
@@ -121,9 +130,12 @@ ol.interaction.DragPan.prototype.handlePointerUp = function(mapBrowserEvent) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.DragPan}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragPan.prototype.handlePointerDown = function(mapBrowserEvent) {
|
||||
ol.interaction.DragPan.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length > 0 && this.condition_(mapBrowserEvent)) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
|
||||
@@ -31,7 +31,11 @@ ol.interaction.DragRotateAndZoom = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleDownEvent: ol.interaction.DragRotateAndZoom.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.DragRotateAndZoom.handleDragEvent_,
|
||||
handleUpEvent: ol.interaction.DragRotateAndZoom.handleUpEvent_
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -64,10 +68,11 @@ goog.inherits(ol.interaction.DragRotateAndZoom,
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragRotateAndZoom}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragRotateAndZoom.prototype.handlePointerDrag =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return;
|
||||
}
|
||||
@@ -101,10 +106,12 @@ ol.interaction.DragRotateAndZoom.prototype.handlePointerDrag =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.DragRotateAndZoom}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragRotateAndZoom.prototype.handlePointerUp =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
@@ -124,10 +131,12 @@ ol.interaction.DragRotateAndZoom.prototype.handlePointerUp =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.DragRotateAndZoom}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragRotateAndZoom.prototype.handlePointerDown =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotateAndZoom.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,11 @@ ol.interaction.DragRotate = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleDownEvent: ol.interaction.DragRotate.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.DragRotate.handleDragEvent_,
|
||||
handleUpEvent: ol.interaction.DragRotate.handleUpEvent_
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -47,10 +51,11 @@ goog.inherits(ol.interaction.DragRotate, ol.interaction.Pointer);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.DragRotate}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragRotate.prototype.handlePointerDrag =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return;
|
||||
}
|
||||
@@ -73,10 +78,12 @@ ol.interaction.DragRotate.prototype.handlePointerDrag =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.DragRotate}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragRotate.prototype.handlePointerUp =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return true;
|
||||
}
|
||||
@@ -92,10 +99,12 @@ ol.interaction.DragRotate.prototype.handlePointerUp =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.DragRotate}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.DragRotate.prototype.handlePointerDown =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.DragRotate.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (!ol.events.condition.mouseOnly(mapBrowserEvent)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,9 @@ goog.inherits(ol.DrawEvent, goog.events.Event);
|
||||
ol.interaction.Draw = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.Draw.handleEvent
|
||||
handleDownEvent: ol.interaction.Draw.handleDownEvent_,
|
||||
handleEvent: ol.interaction.Draw.handleEvent,
|
||||
handleUpEvent: ol.interaction.Draw.handleUpEvent_
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -259,11 +261,12 @@ ol.interaction.Draw.handleEvent = function(mapBrowserEvent) {
|
||||
|
||||
|
||||
/**
|
||||
* Handle down events.
|
||||
* @param {ol.MapBrowserEvent} event A down event.
|
||||
* @return {boolean} Pass the event to other interactions.
|
||||
* @param {ol.MapBrowserPointerEvent} event Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.Draw}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.Draw.prototype.handlePointerDown = function(event) {
|
||||
ol.interaction.Draw.handleDownEvent_ = function(event) {
|
||||
if (this.condition_(event)) {
|
||||
this.downPx_ = event.pixel;
|
||||
return true;
|
||||
@@ -274,11 +277,12 @@ ol.interaction.Draw.prototype.handlePointerDown = function(event) {
|
||||
|
||||
|
||||
/**
|
||||
* Handle up events.
|
||||
* @param {ol.MapBrowserEvent} event An up event.
|
||||
* @return {boolean} Pass the event to other interactions.
|
||||
* @param {ol.MapBrowserPointerEvent} event Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.Draw}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.Draw.prototype.handlePointerUp = function(event) {
|
||||
ol.interaction.Draw.handleUpEvent_ = function(event) {
|
||||
var downPx = this.downPx_;
|
||||
var clickPx = event.pixel;
|
||||
var dx = downPx[0] - clickPx[0];
|
||||
|
||||
@@ -48,7 +48,10 @@ ol.interaction.SegmentDataType;
|
||||
ol.interaction.Modify = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
handleEvent: ol.interaction.Modify.handleEvent
|
||||
handleDownEvent: ol.interaction.Modify.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.Modify.handleDragEvent_,
|
||||
handleEvent: ol.interaction.Modify.handleEvent,
|
||||
handleUpEvent: ol.interaction.Modify.handleUpEvent_
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -389,9 +392,12 @@ ol.interaction.Modify.prototype.createOrUpdateVertexFeature_ =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} evt Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.Modify}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.Modify.prototype.handlePointerDown = function(evt) {
|
||||
ol.interaction.Modify.handleDownEvent_ = function(evt) {
|
||||
this.handlePointerAtPixel_(evt.pixel, evt.map);
|
||||
this.dragSegments_ = [];
|
||||
var vertexFeature = this.vertexFeature_;
|
||||
@@ -421,9 +427,11 @@ ol.interaction.Modify.prototype.handlePointerDown = function(evt) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} evt Event.
|
||||
* @this {ol.interaction.Modify}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.Modify.prototype.handlePointerDrag = function(evt) {
|
||||
ol.interaction.Modify.handleDragEvent_ = function(evt) {
|
||||
var vertex = evt.coordinate;
|
||||
for (var i = 0, ii = this.dragSegments_.length; i < ii; ++i) {
|
||||
var dragSegment = this.dragSegments_[i];
|
||||
@@ -472,9 +480,12 @@ ol.interaction.Modify.prototype.handlePointerDrag = function(evt) {
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} evt Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.Modify}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.Modify.prototype.handlePointerUp = function(evt) {
|
||||
ol.interaction.Modify.handleUpEvent_ = function(evt) {
|
||||
var segmentData;
|
||||
for (var i = this.dragSegments_.length - 1; i >= 0; --i) {
|
||||
segmentData = this.dragSegments_[i][0];
|
||||
|
||||
@@ -22,7 +22,11 @@ goog.require('ol.interaction.Pointer');
|
||||
*/
|
||||
ol.interaction.PinchRotate = function(opt_options) {
|
||||
|
||||
goog.base(this);
|
||||
goog.base(this, {
|
||||
handleDownEvent: ol.interaction.PinchRotate.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.PinchRotate.handleDragEvent_,
|
||||
handleUpEvent: ol.interaction.PinchRotate.handleUpEvent_
|
||||
});
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
@@ -61,10 +65,11 @@ goog.inherits(ol.interaction.PinchRotate, ol.interaction.Pointer);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.PinchRotate}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.PinchRotate.prototype.handlePointerDrag =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
goog.asserts.assert(this.targetPointers.length >= 2);
|
||||
var rotationDelta = 0.0;
|
||||
|
||||
@@ -111,10 +116,12 @@ ol.interaction.PinchRotate.prototype.handlePointerDrag =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.PinchRotate}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.PinchRotate.prototype.handlePointerUp =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length < 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
@@ -133,10 +140,12 @@ ol.interaction.PinchRotate.prototype.handlePointerUp =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.PinchRotate}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.PinchRotate.prototype.handlePointerDown =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.PinchRotate.handleDownEvent_ = function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length >= 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
this.anchor_ = null;
|
||||
|
||||
@@ -21,9 +21,13 @@ goog.require('ol.interaction.Pointer');
|
||||
*/
|
||||
ol.interaction.PinchZoom = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
goog.base(this, {
|
||||
handleDownEvent: ol.interaction.PinchZoom.handleDownEvent_,
|
||||
handleDragEvent: ol.interaction.PinchZoom.handleDragEvent_,
|
||||
handleUpEvent: ol.interaction.PinchZoom.handleUpEvent_
|
||||
});
|
||||
|
||||
goog.base(this);
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -54,10 +58,11 @@ goog.inherits(ol.interaction.PinchZoom, ol.interaction.Pointer);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.PinchZoom}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.PinchZoom.prototype.handlePointerDrag =
|
||||
function(mapBrowserEvent) {
|
||||
ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
goog.asserts.assert(this.targetPointers.length >= 2);
|
||||
var scaleDelta = 1.0;
|
||||
|
||||
@@ -98,9 +103,12 @@ ol.interaction.PinchZoom.prototype.handlePointerDrag =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Stop drag sequence?
|
||||
* @this {ol.interaction.PinchZoom}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.PinchZoom.prototype.handlePointerUp =
|
||||
ol.interaction.PinchZoom.handleUpEvent_ =
|
||||
function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length < 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
@@ -121,9 +129,12 @@ ol.interaction.PinchZoom.prototype.handlePointerUp =
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @return {boolean} Start drag sequence?
|
||||
* @this {ol.interaction.PinchZoom}
|
||||
* @private
|
||||
*/
|
||||
ol.interaction.PinchZoom.prototype.handlePointerDown =
|
||||
ol.interaction.PinchZoom.handleDownEvent_ =
|
||||
function(mapBrowserEvent) {
|
||||
if (this.targetPointers.length >= 2) {
|
||||
var map = mapBrowserEvent.map;
|
||||
|
||||
@@ -3,7 +3,6 @@ goog.provide('ol.interaction.Pointer');
|
||||
goog.require('goog.asserts');
|
||||
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');
|
||||
@@ -13,8 +12,13 @@ goog.require('ol.interaction.Interaction');
|
||||
|
||||
/**
|
||||
* @classdesc
|
||||
* Abstract base class; normally only used for creating subclasses and not
|
||||
* instantiated in apps.
|
||||
* Base class that calls user-defined functions on `down`, `move` and `up`
|
||||
* events. This class also manages "drag sequences".
|
||||
*
|
||||
* When the `handleDownEvent` user function returns `true` a drag sequence is
|
||||
* started. During a drag sequence the `handleDragEvent` user function is
|
||||
* called on `move` events. The drag sequence ends when the `handleUpEvent`
|
||||
* user function is called and returns `false`.
|
||||
*
|
||||
* @constructor
|
||||
* @param {olx.interaction.PointerOptions=} opt_options Options.
|
||||
@@ -32,6 +36,34 @@ ol.interaction.Pointer = function(opt_options) {
|
||||
handleEvent: handleEvent
|
||||
});
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent):boolean}
|
||||
* @private
|
||||
*/
|
||||
this.handleDownEvent_ = goog.isDef(options.handleDownEvent) ?
|
||||
options.handleDownEvent : ol.interaction.Pointer.handleDownEvent;
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent)}
|
||||
* @private
|
||||
*/
|
||||
this.handleDragEvent_ = goog.isDef(options.handleDragEvent) ?
|
||||
options.handleDragEvent : ol.interaction.Pointer.handleDragEvent;
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent)}
|
||||
* @private
|
||||
*/
|
||||
this.handleMoveEvent_ = goog.isDef(options.handleMoveEvent) ?
|
||||
options.handleMoveEvent : ol.interaction.Pointer.handleMoveEvent;
|
||||
|
||||
/**
|
||||
* @type {function(ol.MapBrowserPointerEvent):boolean}
|
||||
* @private
|
||||
*/
|
||||
this.handleUpEvent_ = goog.isDef(options.handleUpEvent) ?
|
||||
options.handleUpEvent : ol.interaction.Pointer.handleUpEvent;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
* @protected
|
||||
@@ -111,25 +143,32 @@ ol.interaction.Pointer.prototype.updateTrackedPointers_ =
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @protected
|
||||
* @this {ol.interaction.Pointer}
|
||||
*/
|
||||
ol.interaction.Pointer.prototype.handlePointerDrag = goog.nullFunction;
|
||||
ol.interaction.Pointer.handleDragEvent = goog.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @protected
|
||||
* @return {boolean} Capture dragging.
|
||||
* @this {ol.interaction.Pointer}
|
||||
*/
|
||||
ol.interaction.Pointer.prototype.handlePointerUp = goog.functions.FALSE;
|
||||
ol.interaction.Pointer.handleUpEvent = goog.functions.FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @protected
|
||||
* @return {boolean} Capture dragging.
|
||||
* @this {ol.interaction.Pointer}
|
||||
*/
|
||||
ol.interaction.Pointer.prototype.handlePointerDown = goog.functions.FALSE;
|
||||
ol.interaction.Pointer.handleDownEvent = goog.functions.FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.MapBrowserPointerEvent} mapBrowserEvent Event.
|
||||
* @this {ol.interaction.Pointer}
|
||||
*/
|
||||
ol.interaction.Pointer.handleMoveEvent = goog.nullFunction;
|
||||
|
||||
|
||||
/**
|
||||
@@ -148,15 +187,15 @@ ol.interaction.Pointer.handleEvent = function(mapBrowserEvent) {
|
||||
if (this.handlingDownUpSequence) {
|
||||
if (mapBrowserEvent.type ==
|
||||
ol.MapBrowserEvent.EventType.POINTERDRAG) {
|
||||
this.handlePointerDrag(mapBrowserEvent);
|
||||
this.handleDragEvent_(mapBrowserEvent);
|
||||
} else if (mapBrowserEvent.type ==
|
||||
ol.MapBrowserEvent.EventType.POINTERUP) {
|
||||
this.handlingDownUpSequence =
|
||||
this.handlePointerUp(mapBrowserEvent);
|
||||
this.handleUpEvent_(mapBrowserEvent);
|
||||
}
|
||||
}
|
||||
if (mapBrowserEvent.type == ol.MapBrowserEvent.EventType.POINTERDOWN) {
|
||||
var handled = this.handlePointerDown(mapBrowserEvent);
|
||||
var handled = this.handleDownEvent_(mapBrowserEvent);
|
||||
this.handlingDownUpSequence = handled;
|
||||
stopEvent = this.shouldStopEvent(handled);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user