Remove unused map parameter from several interaction methods
This commit is contained in:
@@ -55,7 +55,7 @@ ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
|
||||
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
||||
var view = map.getView();
|
||||
ol.interaction.Interaction.zoomByDelta(
|
||||
map, view, delta, anchor, this.duration_);
|
||||
view, delta, anchor, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
stopEvent = true;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
var view = map.getView();
|
||||
var rotation = view.getRotation();
|
||||
ol.interaction.Interaction.rotateWithoutConstraints(
|
||||
map, view, rotation - delta);
|
||||
view, rotation - delta);
|
||||
}
|
||||
this.lastAngle_ = theta;
|
||||
};
|
||||
@@ -94,7 +94,7 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
var view = map.getView();
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
var rotation = view.getRotation();
|
||||
ol.interaction.Interaction.rotate(map, view, rotation,
|
||||
ol.interaction.Interaction.rotate(view, rotation,
|
||||
undefined, this.duration_);
|
||||
return false;
|
||||
};
|
||||
|
||||
@@ -88,12 +88,12 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
if (this.lastAngle_ !== undefined) {
|
||||
var angleDelta = theta - this.lastAngle_;
|
||||
ol.interaction.Interaction.rotateWithoutConstraints(
|
||||
map, view, view.getRotation() - angleDelta);
|
||||
view, view.getRotation() - angleDelta);
|
||||
}
|
||||
this.lastAngle_ = theta;
|
||||
if (this.lastMagnitude_ !== undefined) {
|
||||
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
|
||||
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution);
|
||||
ol.interaction.Interaction.zoomWithoutConstraints(view, resolution);
|
||||
}
|
||||
if (this.lastMagnitude_ !== undefined) {
|
||||
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
|
||||
@@ -117,8 +117,8 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
var view = map.getView();
|
||||
view.setHint(ol.ViewHint.INTERACTING, -1);
|
||||
var direction = this.lastScaleDelta_ - 1;
|
||||
ol.interaction.Interaction.rotate(map, view, view.getRotation());
|
||||
ol.interaction.Interaction.zoom(map, view, view.getResolution(),
|
||||
ol.interaction.Interaction.rotate(view, view.getRotation());
|
||||
ol.interaction.Interaction.zoom(view, view.getResolution(),
|
||||
undefined, this.duration_, direction);
|
||||
this.lastScaleDelta_ = 0;
|
||||
return false;
|
||||
|
||||
@@ -91,12 +91,11 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.View} view View.
|
||||
* @param {ol.Coordinate} delta Delta.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
ol.interaction.Interaction.pan = function(map, view, delta, opt_duration) {
|
||||
ol.interaction.Interaction.pan = function(view, delta, opt_duration) {
|
||||
var currentCenter = view.getCenter();
|
||||
if (currentCenter) {
|
||||
var center = view.constrainCenter(
|
||||
@@ -115,27 +114,25 @@ ol.interaction.Interaction.pan = function(map, view, delta, opt_duration) {
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.View} view View.
|
||||
* @param {number|undefined} rotation Rotation.
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
ol.interaction.Interaction.rotate = function(map, view, rotation, opt_anchor, opt_duration) {
|
||||
ol.interaction.Interaction.rotate = function(view, rotation, opt_anchor, opt_duration) {
|
||||
rotation = view.constrainRotation(rotation, 0);
|
||||
ol.interaction.Interaction.rotateWithoutConstraints(
|
||||
map, view, rotation, opt_anchor, opt_duration);
|
||||
view, rotation, opt_anchor, opt_duration);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.View} view View.
|
||||
* @param {number|undefined} rotation Rotation.
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
ol.interaction.Interaction.rotateWithoutConstraints = function(map, view, rotation, opt_anchor, opt_duration) {
|
||||
ol.interaction.Interaction.rotateWithoutConstraints = function(view, rotation, opt_anchor, opt_duration) {
|
||||
if (rotation !== undefined) {
|
||||
var currentRotation = view.getRotation();
|
||||
var currentCenter = view.getCenter();
|
||||
@@ -154,7 +151,6 @@ ol.interaction.Interaction.rotateWithoutConstraints = function(map, view, rotati
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.View} view View.
|
||||
* @param {number|undefined} resolution Resolution to go to.
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
@@ -168,36 +164,34 @@ ol.interaction.Interaction.rotateWithoutConstraints = function(map, view, rotati
|
||||
* will select the nearest resolution. If not defined 0 is
|
||||
* assumed.
|
||||
*/
|
||||
ol.interaction.Interaction.zoom = function(map, view, resolution, opt_anchor, opt_duration, opt_direction) {
|
||||
ol.interaction.Interaction.zoom = function(view, resolution, opt_anchor, opt_duration, opt_direction) {
|
||||
resolution = view.constrainResolution(resolution, 0, opt_direction);
|
||||
ol.interaction.Interaction.zoomWithoutConstraints(
|
||||
map, view, resolution, opt_anchor, opt_duration);
|
||||
view, resolution, opt_anchor, opt_duration);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.View} view View.
|
||||
* @param {number} delta Delta from previous zoom level.
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
ol.interaction.Interaction.zoomByDelta = function(map, view, delta, opt_anchor, opt_duration) {
|
||||
ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) {
|
||||
var currentResolution = view.getResolution();
|
||||
var resolution = view.constrainResolution(currentResolution, delta, 0);
|
||||
ol.interaction.Interaction.zoomWithoutConstraints(
|
||||
map, view, resolution, opt_anchor, opt_duration);
|
||||
view, resolution, opt_anchor, opt_duration);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {ol.View} view View.
|
||||
* @param {number|undefined} resolution Resolution to go to.
|
||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||
* @param {number=} opt_duration Duration.
|
||||
*/
|
||||
ol.interaction.Interaction.zoomWithoutConstraints = function(map, view, resolution, opt_anchor, opt_duration) {
|
||||
ol.interaction.Interaction.zoomWithoutConstraints = function(view, resolution, opt_anchor, opt_duration) {
|
||||
if (resolution) {
|
||||
var currentResolution = view.getResolution();
|
||||
var currentCenter = view.getCenter();
|
||||
|
||||
@@ -100,7 +100,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
|
||||
}
|
||||
var delta = [deltaX, deltaY];
|
||||
ol.coordinate.rotate(delta, view.getRotation());
|
||||
ol.interaction.Interaction.pan(map, view, delta, this.duration_);
|
||||
ol.interaction.Interaction.pan(view, delta, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
stopEvent = true;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
|
||||
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||
var view = map.getView();
|
||||
ol.interaction.Interaction.zoomByDelta(
|
||||
map, view, delta, undefined, this.duration_);
|
||||
view, delta, undefined, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
stopEvent = true;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
|
||||
}
|
||||
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
|
||||
var delta = ol.math.clamp(this.delta_, -maxDelta, maxDelta);
|
||||
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
||||
ol.interaction.Interaction.zoomByDelta(view, -delta, this.lastAnchor_,
|
||||
this.duration_);
|
||||
this.mode_ = undefined;
|
||||
this.delta_ = 0;
|
||||
|
||||
@@ -110,7 +110,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
var view = map.getView();
|
||||
var rotation = view.getRotation();
|
||||
map.render();
|
||||
ol.interaction.Interaction.rotateWithoutConstraints(map, view,
|
||||
ol.interaction.Interaction.rotateWithoutConstraints(view,
|
||||
rotation + rotationDelta, this.anchor_);
|
||||
}
|
||||
};
|
||||
@@ -130,7 +130,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
if (this.rotating_) {
|
||||
var rotation = view.getRotation();
|
||||
ol.interaction.Interaction.rotate(
|
||||
map, view, rotation, this.anchor_, this.duration_);
|
||||
view, rotation, this.anchor_, this.duration_);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@@ -99,7 +99,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
|
||||
// scale, bypass the resolution constraint
|
||||
map.render();
|
||||
ol.interaction.Interaction.zoomWithoutConstraints(
|
||||
map, view, resolution * scaleDelta, this.anchor_);
|
||||
view, resolution * scaleDelta, this.anchor_);
|
||||
};
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
|
||||
// direction not to zoom out/in if user was pinching in/out.
|
||||
// Direction is > 0 if pinching out, and < 0 if pinching in.
|
||||
var direction = this.lastScaleDelta_ - 1;
|
||||
ol.interaction.Interaction.zoom(map, view, resolution,
|
||||
ol.interaction.Interaction.zoom(view, resolution,
|
||||
this.anchor_, this.duration_, direction);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -40,10 +40,10 @@ describe('ol.interaction.KeyboardPan', function() {
|
||||
map.handleMapBrowserEvent(event);
|
||||
event.originalEvent.keyCode = 39; // RIGHT
|
||||
map.handleMapBrowserEvent(event);
|
||||
expect(spy.getCall(0).args[2]).to.eql([0, -128]);
|
||||
expect(spy.getCall(1).args[2]).to.eql([0, 128]);
|
||||
expect(spy.getCall(2).args[2]).to.eql([-128, 0]);
|
||||
expect(spy.getCall(3).args[2]).to.eql([128, 0]);
|
||||
expect(spy.getCall(0).args[1]).to.eql([0, -128]);
|
||||
expect(spy.getCall(1).args[1]).to.eql([0, 128]);
|
||||
expect(spy.getCall(2).args[1]).to.eql([-128, 0]);
|
||||
expect(spy.getCall(3).args[1]).to.eql([128, 0]);
|
||||
ol.interaction.Interaction.pan.restore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -36,8 +36,8 @@ describe('ol.interaction.KeyboardZoom', function() {
|
||||
map.handleMapBrowserEvent(event);
|
||||
event.originalEvent.charCode = '-'.charCodeAt(0);
|
||||
map.handleMapBrowserEvent(event);
|
||||
expect(spy.getCall(0).args[2]).to.eql(1);
|
||||
expect(spy.getCall(1).args[2]).to.eql(-1);
|
||||
expect(spy.getCall(0).args[1]).to.eql(1);
|
||||
expect(spy.getCall(1).args[1]).to.eql(-1);
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,8 +106,8 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
it('works in DOM_DELTA_LINE mode (wheel)', function(done) {
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
map.once('postrender', function() {
|
||||
expect(spy.getCall(0).args[2]).to.be(-1);
|
||||
expect(spy.getCall(0).args[3]).to.eql([0, 0]);
|
||||
expect(spy.getCall(0).args[1]).to.be(-1);
|
||||
expect(spy.getCall(0).args[2]).to.eql([0, 0]);
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
done();
|
||||
});
|
||||
@@ -127,8 +127,8 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
ol.has.SAFARI = true;
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
map.once('postrender', function() {
|
||||
expect(spy.getCall(0).args[2]).to.be(-1);
|
||||
expect(spy.getCall(0).args[3]).to.eql([0, 0]);
|
||||
expect(spy.getCall(0).args[1]).to.be(-1);
|
||||
expect(spy.getCall(0).args[2]).to.eql([0, 0]);
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
ol.has.SAFARI = origHasSafari;
|
||||
done();
|
||||
@@ -148,8 +148,8 @@ describe('ol.interaction.MouseWheelZoom', function() {
|
||||
ol.has.SAFARI = false;
|
||||
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
|
||||
map.once('postrender', function() {
|
||||
expect(spy.getCall(0).args[2]).to.be(-1);
|
||||
expect(spy.getCall(0).args[3]).to.eql([0, 0]);
|
||||
expect(spy.getCall(0).args[1]).to.be(-1);
|
||||
expect(spy.getCall(0).args[2]).to.eql([0, 0]);
|
||||
ol.interaction.Interaction.zoomByDelta.restore();
|
||||
ol.has.SAFARI = origHasSafari;
|
||||
done();
|
||||
|
||||
Reference in New Issue
Block a user