From 9586c7cbc7a82fedc75b1577285e7e1641ec1c66 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Wed, 3 Oct 2018 12:54:45 +0200 Subject: [PATCH] Get rid of private handler members --- src/ol/interaction/Pointer.js | 44 +++++++------------ .../ol/interaction/dragrotateandzoom.test.js | 6 +-- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/src/ol/interaction/Pointer.js b/src/ol/interaction/Pointer.js index c7af31aa39..4a20e7c06b 100644 --- a/src/ol/interaction/Pointer.js +++ b/src/ol/interaction/Pointer.js @@ -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; diff --git a/test/spec/ol/interaction/dragrotateandzoom.test.js b/test/spec/ol/interaction/dragrotateandzoom.test.js index b8d91435bd..7a9249182e 100644 --- a/test/spec/ol/interaction/dragrotateandzoom.test.js +++ b/test/spec/ol/interaction/dragrotateandzoom.test.js @@ -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(); });