From e8aae600664e45dea3dc5eb37cb2f74587743541 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 12 Feb 2018 06:23:39 -0700 Subject: [PATCH] Remove private static members from MouseWheelZoom interaction --- src/ol/interaction/MouseWheelZoom.js | 25 ++++++++++--------- .../ol/interaction/mousewheelzoom.test.js | 6 ++--- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/ol/interaction/MouseWheelZoom.js b/src/ol/interaction/MouseWheelZoom.js index 43f404f6b3..a7dfe19d8e 100644 --- a/src/ol/interaction/MouseWheelZoom.js +++ b/src/ol/interaction/MouseWheelZoom.js @@ -18,6 +18,15 @@ import {clamp} from '../math.js'; const MAX_DELTA = 1; +/** + * @enum {string} + */ +export const Mode = { + TRACKPAD: 'trackpad', + WHEEL: 'wheel' +}; + + /** * @classdesc * Allows the user to zoom the map by scrolling the mouse wheel. @@ -91,7 +100,7 @@ const MouseWheelZoom = function(opt_options) { /** * @private - * @type {ol.interaction.MouseWheelZoom.Mode_|undefined} + * @type {ol.interaction.Mode|undefined} */ this.mode_ = undefined; @@ -183,11 +192,11 @@ MouseWheelZoom.handleEvent = function(mapBrowserEvent) { if (!this.mode_ || now - this.startTime_ > this.trackpadEventGap_) { this.mode_ = Math.abs(delta) < 4 ? - MouseWheelZoom.Mode_.TRACKPAD : - MouseWheelZoom.Mode_.WHEEL; + Mode.TRACKPAD : + Mode.WHEEL; } - if (this.mode_ === MouseWheelZoom.Mode_.TRACKPAD) { + if (this.mode_ === Mode.TRACKPAD) { const view = map.getView(); if (this.trackpadTimeoutId_) { clearTimeout(this.trackpadTimeoutId_); @@ -296,12 +305,4 @@ MouseWheelZoom.prototype.setMouseAnchor = function(useAnchor) { }; -/** - * @enum {string} - * @private - */ -MouseWheelZoom.Mode_ = { - TRACKPAD: 'trackpad', - WHEEL: 'wheel' -}; export default MouseWheelZoom; diff --git a/test/spec/ol/interaction/mousewheelzoom.test.js b/test/spec/ol/interaction/mousewheelzoom.test.js index f52eb23cae..5f55163cc4 100644 --- a/test/spec/ol/interaction/mousewheelzoom.test.js +++ b/test/spec/ol/interaction/mousewheelzoom.test.js @@ -4,7 +4,7 @@ import View from '../../../../src/ol/View.js'; import Event from '../../../../src/ol/events/Event.js'; import {DEVICE_PIXEL_RATIO, FIREFOX, SAFARI} from '../../../../src/ol/has.js'; import Interaction from '../../../../src/ol/interaction/Interaction.js'; -import MouseWheelZoom from '../../../../src/ol/interaction/MouseWheelZoom.js'; +import MouseWheelZoom, {Mode} from '../../../../src/ol/interaction/MouseWheelZoom.js'; describe('ol.interaction.MouseWheelZoom', function() { @@ -65,7 +65,7 @@ describe('ol.interaction.MouseWheelZoom', function() { if (FIREFOX) { it('works on Firefox in DOM_DELTA_PIXEL mode (trackpad)', function(done) { map.once('postrender', function() { - expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD); + expect(interaction.mode_).to.be(Mode.TRACKPAD); done(); }); const event = new MapBrowserEvent('wheel', map, { @@ -83,7 +83,7 @@ describe('ol.interaction.MouseWheelZoom', function() { if (!FIREFOX) { it('works in DOM_DELTA_PIXEL mode (trackpad)', function(done) { map.once('postrender', function() { - expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD); + expect(interaction.mode_).to.be(Mode.TRACKPAD); done(); }); const event = new MapBrowserEvent('wheel', map, {