Get rid of private handler members

This commit is contained in:
ahocevar
2018-10-03 12:54:45 +02:00
committed by Kevin Schmidt
parent 18570841d8
commit 9586c7cbc7
2 changed files with 19 additions and 31 deletions

View File

@@ -56,33 +56,21 @@ class PointerInteraction extends Interaction {
handleEvent: options.handleEvent || handleEvent
});
/**
* @type {function(MapBrowserPointerEvent):boolean}
* @private
*/
this.handleDownEvent_ = options.handleDownEvent ?
options.handleDownEvent : this.handleDownEvent;
if (options.handleDownEvent) {
this.handleDownEvent = options.handleDownEvent;
}
/**
* @type {function(MapBrowserPointerEvent)}
* @private
*/
this.handleDragEvent_ = options.handleDragEvent ?
options.handleDragEvent : this.handleDragEvent;
if (options.handleDragEvent) {
this.handleDragEvent = options.handleDragEvent;
}
/**
* @type {function(MapBrowserPointerEvent)}
* @private
*/
this.handleMoveEvent_ = options.handleMoveEvent ?
options.handleMoveEvent : this.handleMoveEvent;
if (options.handleMoveEvent) {
this.handleMoveEvent = options.handleMoveEvent;
}
/**
* @type {function(MapBrowserPointerEvent):boolean}
* @private
*/
this.handleUpEvent_ = options.handleUpEvent ?
options.handleUpEvent : this.handleUpEvent;
if (options.handleUpEvent) {
this.handleUpEvent = options.handleUpEvent;
}
/**
* @type {boolean}
@@ -218,21 +206,21 @@ export function handleEvent(mapBrowserEvent) {
this.updateTrackedPointers_(mapBrowserEvent);
if (this.handlingDownUpSequence) {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDRAG) {
this.handleDragEvent_(mapBrowserEvent);
this.handleDragEvent(mapBrowserEvent);
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
const handledUp = this.handleUpEvent_(mapBrowserEvent);
const handledUp = this.handleUpEvent(mapBrowserEvent);
this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0;
}
} else {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDOWN) {
const handled = this.handleDownEvent_(mapBrowserEvent);
const handled = this.handleDownEvent(mapBrowserEvent);
if (handled) {
mapBrowserEvent.preventDefault();
}
this.handlingDownUpSequence = handled;
stopEvent = this.stopDown(handled);
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERMOVE) {
this.handleMoveEvent_(mapBrowserEvent);
this.handleMoveEvent(mapBrowserEvent);
}
}
return !stopEvent;

View File

@@ -17,7 +17,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
});
describe('#handleDragEvent_()', function() {
describe('#handleDragEvent()', function() {
let target, map, interaction;
@@ -64,7 +64,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
let view = map.getView();
let spy = sinon.spy(view, 'rotate');
interaction.handleDragEvent_(event);
interaction.handleDragEvent(event);
expect(spy.callCount).to.be(1);
expect(interaction.lastAngle_).to.be(-0.8308214428190254);
view.rotate.restore();
@@ -82,7 +82,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
true);
spy = sinon.spy(view, 'rotate');
interaction.handleDragEvent_(event);
interaction.handleDragEvent(event);
expect(spy.callCount).to.be(0);
view.rotate.restore();
});