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
+16 -28
View File
@@ -56,33 +56,21 @@ class PointerInteraction extends Interaction {
handleEvent: options.handleEvent || handleEvent handleEvent: options.handleEvent || handleEvent
}); });
/** if (options.handleDownEvent) {
* @type {function(MapBrowserPointerEvent):boolean} this.handleDownEvent = options.handleDownEvent;
* @private }
*/
this.handleDownEvent_ = options.handleDownEvent ?
options.handleDownEvent : this.handleDownEvent;
/** if (options.handleDragEvent) {
* @type {function(MapBrowserPointerEvent)} this.handleDragEvent = options.handleDragEvent;
* @private }
*/
this.handleDragEvent_ = options.handleDragEvent ?
options.handleDragEvent : this.handleDragEvent;
/** if (options.handleMoveEvent) {
* @type {function(MapBrowserPointerEvent)} this.handleMoveEvent = options.handleMoveEvent;
* @private }
*/
this.handleMoveEvent_ = options.handleMoveEvent ?
options.handleMoveEvent : this.handleMoveEvent;
/** if (options.handleUpEvent) {
* @type {function(MapBrowserPointerEvent):boolean} this.handleUpEvent = options.handleUpEvent;
* @private }
*/
this.handleUpEvent_ = options.handleUpEvent ?
options.handleUpEvent : this.handleUpEvent;
/** /**
* @type {boolean} * @type {boolean}
@@ -218,21 +206,21 @@ export function handleEvent(mapBrowserEvent) {
this.updateTrackedPointers_(mapBrowserEvent); this.updateTrackedPointers_(mapBrowserEvent);
if (this.handlingDownUpSequence) { if (this.handlingDownUpSequence) {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDRAG) { if (mapBrowserEvent.type == MapBrowserEventType.POINTERDRAG) {
this.handleDragEvent_(mapBrowserEvent); this.handleDragEvent(mapBrowserEvent);
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) { } else if (mapBrowserEvent.type == MapBrowserEventType.POINTERUP) {
const handledUp = this.handleUpEvent_(mapBrowserEvent); const handledUp = this.handleUpEvent(mapBrowserEvent);
this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0; this.handlingDownUpSequence = handledUp && this.targetPointers.length > 0;
} }
} else { } else {
if (mapBrowserEvent.type == MapBrowserEventType.POINTERDOWN) { if (mapBrowserEvent.type == MapBrowserEventType.POINTERDOWN) {
const handled = this.handleDownEvent_(mapBrowserEvent); const handled = this.handleDownEvent(mapBrowserEvent);
if (handled) { if (handled) {
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
} }
this.handlingDownUpSequence = handled; this.handlingDownUpSequence = handled;
stopEvent = this.stopDown(handled); stopEvent = this.stopDown(handled);
} else if (mapBrowserEvent.type == MapBrowserEventType.POINTERMOVE) { } else if (mapBrowserEvent.type == MapBrowserEventType.POINTERMOVE) {
this.handleMoveEvent_(mapBrowserEvent); this.handleMoveEvent(mapBrowserEvent);
} }
} }
return !stopEvent; return !stopEvent;
@@ -17,7 +17,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
}); });
describe('#handleDragEvent_()', function() { describe('#handleDragEvent()', function() {
let target, map, interaction; let target, map, interaction;
@@ -64,7 +64,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
let view = map.getView(); let view = map.getView();
let spy = sinon.spy(view, 'rotate'); let spy = sinon.spy(view, 'rotate');
interaction.handleDragEvent_(event); interaction.handleDragEvent(event);
expect(spy.callCount).to.be(1); expect(spy.callCount).to.be(1);
expect(interaction.lastAngle_).to.be(-0.8308214428190254); expect(interaction.lastAngle_).to.be(-0.8308214428190254);
view.rotate.restore(); view.rotate.restore();
@@ -82,7 +82,7 @@ describe('ol.interaction.DragRotateAndZoom', function() {
true); true);
spy = sinon.spy(view, 'rotate'); spy = sinon.spy(view, 'rotate');
interaction.handleDragEvent_(event); interaction.handleDragEvent(event);
expect(spy.callCount).to.be(0); expect(spy.callCount).to.be(0);
view.rotate.restore(); view.rotate.restore();
}); });