Only export handleEvent where it is used by other interactions

This commit is contained in:
Tim Schaub
2018-02-19 13:56:41 -07:00
parent bca8938a02
commit 1be61fdb09
11 changed files with 35 additions and 50 deletions

View File

@@ -25,7 +25,7 @@ const DoubleClickZoom = function(opt_options) {
this.delta_ = options.delta ? options.delta : 1;
Interaction.call(this, {
handleEvent: DoubleClickZoom.handleEvent
handleEvent: handleEvent
});
/**
@@ -45,9 +45,8 @@ inherits(DoubleClickZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.DoubleClickZoom}
* @api
*/
DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
let stopEvent = false;
const browserEvent = mapBrowserEvent.originalEvent;
if (mapBrowserEvent.type == MapBrowserEventType.DBLCLICK) {
@@ -60,5 +59,6 @@ DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
stopEvent = true;
}
return !stopEvent;
};
}
export default DoubleClickZoom;

View File

@@ -40,7 +40,7 @@ const DragAndDrop = function(opt_options) {
const options = opt_options ? opt_options : {};
Interaction.call(this, {
handleEvent: DragAndDrop.handleEvent
handleEvent: TRUE
});
/**
@@ -152,17 +152,6 @@ DragAndDrop.prototype.handleResult_ = function(file, event) {
};
/**
* Handles the {@link ol.MapBrowserEvent map browser event} unconditionally and
* neither prevents the browser default nor stops event propagation.
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.DragAndDrop}
* @api
*/
DragAndDrop.handleEvent = TRUE;
/**
* @private
*/

View File

@@ -23,7 +23,7 @@ import MouseSource from '../pointer/MouseSource.js';
import Point from '../geom/Point.js';
import Polygon, {fromCircle, makeRegular} from '../geom/Polygon.js';
import DrawEventType from '../interaction/DrawEventType.js';
import PointerInteraction from '../interaction/Pointer.js';
import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import InteractionProperty from '../interaction/Property.js';
import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js';
@@ -398,7 +398,7 @@ export function handleEvent(event) {
pass = false;
}
return PointerInteraction.handleEvent.call(this, event) && pass;
return handlePointerEvent.call(this, event) && pass;
}

View File

@@ -12,7 +12,7 @@ import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js';
import {fromExtent as polygonFromExtent} from '../geom/Polygon.js';
import ExtentEventType from '../interaction/ExtentEventType.js';
import PointerInteraction from '../interaction/Pointer.js';
import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js';
import Style from '../style/Style.js';
@@ -139,7 +139,7 @@ function handleEvent(mapBrowserEvent) {
this.handlePointerMove_(mapBrowserEvent);
}
//call pointer to determine up/down/drag
PointerInteraction.handleEvent.call(this, mapBrowserEvent);
handlePointerEvent.call(this, mapBrowserEvent);
//return false to stop propagation
return false;
}

View File

@@ -28,7 +28,7 @@ import Interaction from '../interaction/Interaction.js';
const KeyboardPan = function(opt_options) {
Interaction.call(this, {
handleEvent: KeyboardPan.handleEvent
handleEvent: handleEvent
});
const options = opt_options || {};
@@ -74,9 +74,8 @@ inherits(KeyboardPan, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardPan}
* @api
*/
KeyboardPan.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN) {
const keyEvent = mapBrowserEvent.originalEvent;
@@ -107,5 +106,6 @@ KeyboardPan.handleEvent = function(mapBrowserEvent) {
}
}
return !stopEvent;
};
}
export default KeyboardPan;

View File

@@ -26,7 +26,7 @@ import Interaction from '../interaction/Interaction.js';
const KeyboardZoom = function(opt_options) {
Interaction.call(this, {
handleEvent: KeyboardZoom.handleEvent
handleEvent: handleEvent
});
const options = opt_options ? opt_options : {};
@@ -61,9 +61,8 @@ inherits(KeyboardZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.KeyboardZoom}
* @api
*/
KeyboardZoom.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
let stopEvent = false;
if (mapBrowserEvent.type == EventType.KEYDOWN ||
mapBrowserEvent.type == EventType.KEYPRESS) {
@@ -81,5 +80,6 @@ KeyboardZoom.handleEvent = function(mapBrowserEvent) {
}
}
return !stopEvent;
};
}
export default KeyboardZoom;

View File

@@ -17,7 +17,7 @@ import {boundingExtent, buffer, createOrUpdateFromCoordinate} from '../extent.js
import GeometryType from '../geom/GeometryType.js';
import Point from '../geom/Point.js';
import ModifyEventType from '../interaction/ModifyEventType.js';
import PointerInteraction from '../interaction/Pointer.js';
import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import VectorLayer from '../layer/Vector.js';
import VectorSource from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js';
@@ -48,7 +48,7 @@ const Modify = function(options) {
PointerInteraction.call(this, {
handleDownEvent: handleDownEvent,
handleDragEvent: handleDragEvent,
handleEvent: Modify.handleEvent,
handleEvent: handleEvent,
handleUpEvent: handleUpEvent
});
@@ -789,9 +789,8 @@ function handleUpEvent(evt) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Modify}
* @api
*/
Modify.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
return true;
}
@@ -815,8 +814,8 @@ Modify.handleEvent = function(mapBrowserEvent) {
this.ignoreNextSingleClick_ = false;
}
return PointerInteraction.handleEvent.call(this, mapBrowserEvent) && !handled;
};
return handlePointerEvent.call(this, mapBrowserEvent) && !handled;
}
/**
@@ -1219,5 +1218,7 @@ Modify.Event = function(type, features, mapBrowserPointerEvent) {
*/
this.mapBrowserEvent = mapBrowserPointerEvent;
};
inherits(Modify.Event, Event);
export default Modify;

View File

@@ -39,7 +39,7 @@ export const Mode = {
const MouseWheelZoom = function(opt_options) {
Interaction.call(this, {
handleEvent: MouseWheelZoom.handleEvent
handleEvent: handleEvent
});
const options = opt_options || {};
@@ -141,9 +141,8 @@ inherits(MouseWheelZoom, Interaction);
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} Allow event propagation.
* @this {ol.interaction.MouseWheelZoom}
* @api
*/
MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) {
return true;
}
@@ -257,7 +256,7 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
this.timeoutId_ = setTimeout(this.handleWheelZoom_.bind(this, map), timeLeft);
return false;
};
}
/**

View File

@@ -27,11 +27,8 @@ const PointerInteraction = function(opt_options) {
const options = opt_options ? opt_options : {};
const handleEvent = options.handleEvent ?
options.handleEvent : PointerInteraction.handleEvent;
Interaction.call(this, {
handleEvent: handleEvent
handleEvent: options.handleEvent || handleEvent
});
/**
@@ -177,7 +174,7 @@ PointerInteraction.handleMoveEvent = nullFunction;
* @this {ol.interaction.Pointer}
* @api
*/
PointerInteraction.handleEvent = function(mapBrowserEvent) {
export function handleEvent(mapBrowserEvent) {
if (!(mapBrowserEvent instanceof MapBrowserPointerEvent)) {
return true;
}
@@ -201,7 +198,7 @@ PointerInteraction.handleEvent = function(mapBrowserEvent) {
}
}
return !stopEvent;
};
}
/**

View File

@@ -50,7 +50,7 @@ const SelectEventType = {
const Select = function(opt_options) {
Interaction.call(this, {
handleEvent: Select.handleEvent
handleEvent: handleEvent
});
const options = opt_options ? opt_options : {};
@@ -207,9 +207,8 @@ Select.prototype.getLayer = function(feature) {
* @param {ol.MapBrowserEvent} mapBrowserEvent Map browser event.
* @return {boolean} `false` to stop event propagation.
* @this {ol.interaction.Select}
* @api
*/
Select.handleEvent = function(mapBrowserEvent) {
function handleEvent(mapBrowserEvent) {
if (!this.condition_(mapBrowserEvent)) {
return true;
}
@@ -294,7 +293,7 @@ Select.handleEvent = function(mapBrowserEvent) {
selected, deselected, mapBrowserEvent));
}
return pointerMove(mapBrowserEvent);
};
}
/**

View File

@@ -11,7 +11,7 @@ import {boundingExtent, createEmpty} from '../extent.js';
import {TRUE, FALSE} from '../functions.js';
import GeometryType from '../geom/GeometryType.js';
import {fromCircle} from '../geom/Polygon.js';
import PointerInteraction from '../interaction/Pointer.js';
import PointerInteraction, {handleEvent as handlePointerEvent} from '../interaction/Pointer.js';
import {getValues} from '../obj.js';
import VectorSource from '../source/Vector.js';
import VectorEventType from '../source/VectorEventType.js';
@@ -590,7 +590,7 @@ export function handleEvent(evt) {
evt.coordinate = result.vertex.slice(0, 2);
evt.pixel = result.vertexPixel;
}
return PointerInteraction.handleEvent.call(this, evt);
return handlePointerEvent.call(this, evt);
}