Rename _ol_interaction_MouseWheelZoom_ to MouseWheelZoom
This commit is contained in:
@@ -1,14 +1,14 @@
|
|||||||
import Map from '../src/ol/Map.js';
|
import Map from '../src/ol/Map.js';
|
||||||
import _ol_View_ from '../src/ol/View.js';
|
import _ol_View_ from '../src/ol/View.js';
|
||||||
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
import {defaults as defaultInteractions} from '../src/ol/interaction.js';
|
||||||
import _ol_interaction_MouseWheelZoom_ from '../src/ol/interaction/MouseWheelZoom.js';
|
import MouseWheelZoom from '../src/ol/interaction/MouseWheelZoom.js';
|
||||||
import TileLayer from '../src/ol/layer/Tile.js';
|
import TileLayer from '../src/ol/layer/Tile.js';
|
||||||
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
import _ol_source_OSM_ from '../src/ol/source/OSM.js';
|
||||||
|
|
||||||
|
|
||||||
var map = new Map({
|
var map = new Map({
|
||||||
interactions: defaultInteractions({mouseWheelZoom: false}).extend([
|
interactions: defaultInteractions({mouseWheelZoom: false}).extend([
|
||||||
new _ol_interaction_MouseWheelZoom_({
|
new MouseWheelZoom({
|
||||||
constrainResolution: true // force zooming to a integer zoom
|
constrainResolution: true // force zooming to a integer zoom
|
||||||
})
|
})
|
||||||
]),
|
]),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import DragRotate from './interaction/DragRotate.js';
|
|||||||
import DragZoom from './interaction/DragZoom.js';
|
import DragZoom from './interaction/DragZoom.js';
|
||||||
import _ol_interaction_KeyboardPan_ from './interaction/KeyboardPan.js';
|
import _ol_interaction_KeyboardPan_ from './interaction/KeyboardPan.js';
|
||||||
import _ol_interaction_KeyboardZoom_ from './interaction/KeyboardZoom.js';
|
import _ol_interaction_KeyboardZoom_ from './interaction/KeyboardZoom.js';
|
||||||
import _ol_interaction_MouseWheelZoom_ from './interaction/MouseWheelZoom.js';
|
import MouseWheelZoom from './interaction/MouseWheelZoom.js';
|
||||||
import _ol_interaction_PinchRotate_ from './interaction/PinchRotate.js';
|
import _ol_interaction_PinchRotate_ from './interaction/PinchRotate.js';
|
||||||
import _ol_interaction_PinchZoom_ from './interaction/PinchZoom.js';
|
import _ol_interaction_PinchZoom_ from './interaction/PinchZoom.js';
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ export function defaults(opt_options) {
|
|||||||
var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
|
var mouseWheelZoom = options.mouseWheelZoom !== undefined ?
|
||||||
options.mouseWheelZoom : true;
|
options.mouseWheelZoom : true;
|
||||||
if (mouseWheelZoom) {
|
if (mouseWheelZoom) {
|
||||||
interactions.push(new _ol_interaction_MouseWheelZoom_({
|
interactions.push(new MouseWheelZoom({
|
||||||
constrainResolution: options.constrainResolution,
|
constrainResolution: options.constrainResolution,
|
||||||
duration: options.zoomDuration
|
duration: options.zoomDuration
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ var MAX_DELTA = 1;
|
|||||||
* @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options.
|
* @param {olx.interaction.MouseWheelZoomOptions=} opt_options Options.
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
var _ol_interaction_MouseWheelZoom_ = function(opt_options) {
|
var MouseWheelZoom = function(opt_options) {
|
||||||
|
|
||||||
Interaction.call(this, {
|
Interaction.call(this, {
|
||||||
handleEvent: _ol_interaction_MouseWheelZoom_.handleEvent
|
handleEvent: MouseWheelZoom.handleEvent
|
||||||
});
|
});
|
||||||
|
|
||||||
var options = opt_options || {};
|
var options = opt_options || {};
|
||||||
@@ -115,7 +115,7 @@ var _ol_interaction_MouseWheelZoom_ = function(opt_options) {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
inherits(_ol_interaction_MouseWheelZoom_, Interaction);
|
inherits(MouseWheelZoom, Interaction);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -126,7 +126,7 @@ inherits(_ol_interaction_MouseWheelZoom_, Interaction);
|
|||||||
* @this {ol.interaction.MouseWheelZoom}
|
* @this {ol.interaction.MouseWheelZoom}
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) {
|
MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
||||||
var type = mapBrowserEvent.type;
|
var type = mapBrowserEvent.type;
|
||||||
if (type !== EventType.WHEEL && type !== EventType.MOUSEWHEEL) {
|
if (type !== EventType.WHEEL && type !== EventType.MOUSEWHEEL) {
|
||||||
return true;
|
return true;
|
||||||
@@ -172,11 +172,11 @@ _ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) {
|
|||||||
|
|
||||||
if (!this.mode_ || now - this.startTime_ > this.trackpadEventGap_) {
|
if (!this.mode_ || now - this.startTime_ > this.trackpadEventGap_) {
|
||||||
this.mode_ = Math.abs(delta) < 4 ?
|
this.mode_ = Math.abs(delta) < 4 ?
|
||||||
_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD :
|
MouseWheelZoom.Mode_.TRACKPAD :
|
||||||
_ol_interaction_MouseWheelZoom_.Mode_.WHEEL;
|
MouseWheelZoom.Mode_.WHEEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mode_ === _ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD) {
|
if (this.mode_ === MouseWheelZoom.Mode_.TRACKPAD) {
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
if (this.trackpadTimeoutId_) {
|
if (this.trackpadTimeoutId_) {
|
||||||
clearTimeout(this.trackpadTimeoutId_);
|
clearTimeout(this.trackpadTimeoutId_);
|
||||||
@@ -243,7 +243,7 @@ _ol_interaction_MouseWheelZoom_.handleEvent = function(mapBrowserEvent) {
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_MouseWheelZoom_.prototype.decrementInteractingHint_ = function() {
|
MouseWheelZoom.prototype.decrementInteractingHint_ = function() {
|
||||||
this.trackpadTimeoutId_ = undefined;
|
this.trackpadTimeoutId_ = undefined;
|
||||||
var view = this.getMap().getView();
|
var view = this.getMap().getView();
|
||||||
view.setHint(_ol_ViewHint_.INTERACTING, -1);
|
view.setHint(_ol_ViewHint_.INTERACTING, -1);
|
||||||
@@ -254,7 +254,7 @@ _ol_interaction_MouseWheelZoom_.prototype.decrementInteractingHint_ = function()
|
|||||||
* @private
|
* @private
|
||||||
* @param {ol.PluggableMap} map Map.
|
* @param {ol.PluggableMap} map Map.
|
||||||
*/
|
*/
|
||||||
_ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) {
|
MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
|
||||||
var view = map.getView();
|
var view = map.getView();
|
||||||
if (view.getAnimating()) {
|
if (view.getAnimating()) {
|
||||||
view.cancelAnimations();
|
view.cancelAnimations();
|
||||||
@@ -277,7 +277,7 @@ _ol_interaction_MouseWheelZoom_.prototype.handleWheelZoom_ = function(map) {
|
|||||||
* to zoom to the center of the map
|
* to zoom to the center of the map
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
_ol_interaction_MouseWheelZoom_.prototype.setMouseAnchor = function(useAnchor) {
|
MouseWheelZoom.prototype.setMouseAnchor = function(useAnchor) {
|
||||||
this.useAnchor_ = useAnchor;
|
this.useAnchor_ = useAnchor;
|
||||||
if (!useAnchor) {
|
if (!useAnchor) {
|
||||||
this.lastAnchor_ = null;
|
this.lastAnchor_ = null;
|
||||||
@@ -289,8 +289,8 @@ _ol_interaction_MouseWheelZoom_.prototype.setMouseAnchor = function(useAnchor) {
|
|||||||
* @enum {string}
|
* @enum {string}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_ol_interaction_MouseWheelZoom_.Mode_ = {
|
MouseWheelZoom.Mode_ = {
|
||||||
TRACKPAD: 'trackpad',
|
TRACKPAD: 'trackpad',
|
||||||
WHEEL: 'wheel'
|
WHEEL: 'wheel'
|
||||||
};
|
};
|
||||||
export default _ol_interaction_MouseWheelZoom_;
|
export default MouseWheelZoom;
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import _ol_View_ from '../../../../src/ol/View.js';
|
|||||||
import Event from '../../../../src/ol/events/Event.js';
|
import Event from '../../../../src/ol/events/Event.js';
|
||||||
import _ol_has_ from '../../../../src/ol/has.js';
|
import _ol_has_ from '../../../../src/ol/has.js';
|
||||||
import Interaction from '../../../../src/ol/interaction/Interaction.js';
|
import Interaction from '../../../../src/ol/interaction/Interaction.js';
|
||||||
import _ol_interaction_MouseWheelZoom_ from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
import MouseWheelZoom from '../../../../src/ol/interaction/MouseWheelZoom.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.interaction.MouseWheelZoom', function() {
|
describe('ol.interaction.MouseWheelZoom', function() {
|
||||||
var map, interaction;
|
var map, interaction;
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
interaction = new _ol_interaction_MouseWheelZoom_();
|
interaction = new MouseWheelZoom();
|
||||||
map = new Map({
|
map = new Map({
|
||||||
target: createMapDiv(100, 100),
|
target: createMapDiv(100, 100),
|
||||||
interactions: [interaction],
|
interactions: [interaction],
|
||||||
@@ -66,7 +66,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
|||||||
var origHasFirefox = _ol_has_.FIREFOX;
|
var origHasFirefox = _ol_has_.FIREFOX;
|
||||||
_ol_has_.FIREFOX = true;
|
_ol_has_.FIREFOX = true;
|
||||||
map.once('postrender', function() {
|
map.once('postrender', function() {
|
||||||
expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD);
|
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||||
_ol_has_.FIREFOX = origHasFirefox;
|
_ol_has_.FIREFOX = origHasFirefox;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
@@ -85,7 +85,7 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
|||||||
var origHasFirefox = _ol_has_.FIREFOX;
|
var origHasFirefox = _ol_has_.FIREFOX;
|
||||||
_ol_has_.FIREFOX = false;
|
_ol_has_.FIREFOX = false;
|
||||||
map.once('postrender', function() {
|
map.once('postrender', function() {
|
||||||
expect(interaction.mode_).to.be(_ol_interaction_MouseWheelZoom_.Mode_.TRACKPAD);
|
expect(interaction.mode_).to.be(MouseWheelZoom.Mode_.TRACKPAD);
|
||||||
_ol_has_.FIREFOX = origHasFirefox;
|
_ol_has_.FIREFOX = origHasFirefox;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import _ol_has_ from '../../../src/ol/has.js';
|
|||||||
import {defaults as defaultInteractions} from '../../../src/ol/interaction.js';
|
import {defaults as defaultInteractions} from '../../../src/ol/interaction.js';
|
||||||
import DoubleClickZoom from '../../../src/ol/interaction/DoubleClickZoom.js';
|
import DoubleClickZoom from '../../../src/ol/interaction/DoubleClickZoom.js';
|
||||||
import Interaction from '../../../src/ol/interaction/Interaction.js';
|
import Interaction from '../../../src/ol/interaction/Interaction.js';
|
||||||
import _ol_interaction_MouseWheelZoom_ from '../../../src/ol/interaction/MouseWheelZoom.js';
|
import MouseWheelZoom from '../../../src/ol/interaction/MouseWheelZoom.js';
|
||||||
import _ol_interaction_PinchZoom_ from '../../../src/ol/interaction/PinchZoom.js';
|
import _ol_interaction_PinchZoom_ from '../../../src/ol/interaction/PinchZoom.js';
|
||||||
import TileLayer from '../../../src/ol/layer/Tile.js';
|
import TileLayer from '../../../src/ol/layer/Tile.js';
|
||||||
import _ol_layer_Vector_ from '../../../src/ol/layer/Vector.js';
|
import _ol_layer_Vector_ from '../../../src/ol/layer/Vector.js';
|
||||||
@@ -482,7 +482,7 @@ describe('ol.Map', function() {
|
|||||||
options.mouseWheelZoom = true;
|
options.mouseWheelZoom = true;
|
||||||
var interactions = defaultInteractions(options);
|
var interactions = defaultInteractions(options);
|
||||||
expect(interactions.getLength()).to.eql(1);
|
expect(interactions.getLength()).to.eql(1);
|
||||||
expect(interactions.item(0)).to.be.a(_ol_interaction_MouseWheelZoom_);
|
expect(interactions.item(0)).to.be.a(MouseWheelZoom);
|
||||||
expect(interactions.item(0).constrainResolution_).to.eql(false);
|
expect(interactions.item(0).constrainResolution_).to.eql(false);
|
||||||
expect(interactions.item(0).useAnchor_).to.eql(true);
|
expect(interactions.item(0).useAnchor_).to.eql(true);
|
||||||
interactions.item(0).setMouseAnchor(false);
|
interactions.item(0).setMouseAnchor(false);
|
||||||
@@ -509,7 +509,7 @@ describe('ol.Map', function() {
|
|||||||
expect(interactions.getLength()).to.eql(2);
|
expect(interactions.getLength()).to.eql(2);
|
||||||
expect(interactions.item(0)).to.be.a(_ol_interaction_PinchZoom_);
|
expect(interactions.item(0)).to.be.a(_ol_interaction_PinchZoom_);
|
||||||
expect(interactions.item(0).constrainResolution_).to.eql(true);
|
expect(interactions.item(0).constrainResolution_).to.eql(true);
|
||||||
expect(interactions.item(1)).to.be.a(_ol_interaction_MouseWheelZoom_);
|
expect(interactions.item(1)).to.be.a(MouseWheelZoom);
|
||||||
expect(interactions.item(1).constrainResolution_).to.eql(true);
|
expect(interactions.item(1).constrainResolution_).to.eql(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user