Remove unused map parameter from several interaction methods

This commit is contained in:
Thomas Chandelle
2017-01-05 15:34:47 +01:00
parent b5af8e4783
commit 8956a492eb
12 changed files with 35 additions and 41 deletions

View File

@@ -55,7 +55,7 @@ ol.interaction.DoubleClickZoom.handleEvent = function(mapBrowserEvent) {
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_; var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
var view = map.getView(); var view = map.getView();
ol.interaction.Interaction.zoomByDelta( ol.interaction.Interaction.zoomByDelta(
map, view, delta, anchor, this.duration_); view, delta, anchor, this.duration_);
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
stopEvent = true; stopEvent = true;
} }

View File

@@ -73,7 +73,7 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
var view = map.getView(); var view = map.getView();
var rotation = view.getRotation(); var rotation = view.getRotation();
ol.interaction.Interaction.rotateWithoutConstraints( ol.interaction.Interaction.rotateWithoutConstraints(
map, view, rotation - delta); view, rotation - delta);
} }
this.lastAngle_ = theta; this.lastAngle_ = theta;
}; };
@@ -94,7 +94,7 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
var view = map.getView(); var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
var rotation = view.getRotation(); var rotation = view.getRotation();
ol.interaction.Interaction.rotate(map, view, rotation, ol.interaction.Interaction.rotate(view, rotation,
undefined, this.duration_); undefined, this.duration_);
return false; return false;
}; };

View File

@@ -88,12 +88,12 @@ ol.interaction.DragRotateAndZoom.handleDragEvent_ = function(mapBrowserEvent) {
if (this.lastAngle_ !== undefined) { if (this.lastAngle_ !== undefined) {
var angleDelta = theta - this.lastAngle_; var angleDelta = theta - this.lastAngle_;
ol.interaction.Interaction.rotateWithoutConstraints( ol.interaction.Interaction.rotateWithoutConstraints(
map, view, view.getRotation() - angleDelta); view, view.getRotation() - angleDelta);
} }
this.lastAngle_ = theta; this.lastAngle_ = theta;
if (this.lastMagnitude_ !== undefined) { if (this.lastMagnitude_ !== undefined) {
var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude); var resolution = this.lastMagnitude_ * (view.getResolution() / magnitude);
ol.interaction.Interaction.zoomWithoutConstraints(map, view, resolution); ol.interaction.Interaction.zoomWithoutConstraints(view, resolution);
} }
if (this.lastMagnitude_ !== undefined) { if (this.lastMagnitude_ !== undefined) {
this.lastScaleDelta_ = this.lastMagnitude_ / magnitude; this.lastScaleDelta_ = this.lastMagnitude_ / magnitude;
@@ -117,8 +117,8 @@ ol.interaction.DragRotateAndZoom.handleUpEvent_ = function(mapBrowserEvent) {
var view = map.getView(); var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1); view.setHint(ol.ViewHint.INTERACTING, -1);
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.rotate(map, view, view.getRotation()); ol.interaction.Interaction.rotate(view, view.getRotation());
ol.interaction.Interaction.zoom(map, view, view.getResolution(), ol.interaction.Interaction.zoom(view, view.getResolution(),
undefined, this.duration_, direction); undefined, this.duration_, direction);
this.lastScaleDelta_ = 0; this.lastScaleDelta_ = 0;
return false; return false;

View File

@@ -91,12 +91,11 @@ ol.interaction.Interaction.prototype.setMap = function(map) {
/** /**
* @param {ol.Map} map Map.
* @param {ol.View} view View. * @param {ol.View} view View.
* @param {ol.Coordinate} delta Delta. * @param {ol.Coordinate} delta Delta.
* @param {number=} opt_duration Duration. * @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(); var currentCenter = view.getCenter();
if (currentCenter) { if (currentCenter) {
var center = view.constrainCenter( 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 {ol.View} view View.
* @param {number|undefined} rotation Rotation. * @param {number|undefined} rotation Rotation.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @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); rotation = view.constrainRotation(rotation, 0);
ol.interaction.Interaction.rotateWithoutConstraints( 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 {ol.View} view View.
* @param {number|undefined} rotation Rotation. * @param {number|undefined} rotation Rotation.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @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) { if (rotation !== undefined) {
var currentRotation = view.getRotation(); var currentRotation = view.getRotation();
var currentCenter = view.getCenter(); 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 {ol.View} view View.
* @param {number|undefined} resolution Resolution to go to. * @param {number|undefined} resolution Resolution to go to.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @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 * will select the nearest resolution. If not defined 0 is
* assumed. * 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); resolution = view.constrainResolution(resolution, 0, opt_direction);
ol.interaction.Interaction.zoomWithoutConstraints( 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 {ol.View} view View.
* @param {number} delta Delta from previous zoom level. * @param {number} delta Delta from previous zoom level.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @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 currentResolution = view.getResolution();
var resolution = view.constrainResolution(currentResolution, delta, 0); var resolution = view.constrainResolution(currentResolution, delta, 0);
ol.interaction.Interaction.zoomWithoutConstraints( 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 {ol.View} view View.
* @param {number|undefined} resolution Resolution to go to. * @param {number|undefined} resolution Resolution to go to.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate. * @param {ol.Coordinate=} opt_anchor Anchor coordinate.
* @param {number=} opt_duration Duration. * @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) { if (resolution) {
var currentResolution = view.getResolution(); var currentResolution = view.getResolution();
var currentCenter = view.getCenter(); var currentCenter = view.getCenter();

View File

@@ -100,7 +100,7 @@ ol.interaction.KeyboardPan.handleEvent = function(mapBrowserEvent) {
} }
var delta = [deltaX, deltaY]; var delta = [deltaX, deltaY];
ol.coordinate.rotate(delta, view.getRotation()); 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(); mapBrowserEvent.preventDefault();
stopEvent = true; stopEvent = true;
} }

View File

@@ -75,7 +75,7 @@ ol.interaction.KeyboardZoom.handleEvent = function(mapBrowserEvent) {
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_; var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
var view = map.getView(); var view = map.getView();
ol.interaction.Interaction.zoomByDelta( ol.interaction.Interaction.zoomByDelta(
map, view, delta, undefined, this.duration_); view, delta, undefined, this.duration_);
mapBrowserEvent.preventDefault(); mapBrowserEvent.preventDefault();
stopEvent = true; stopEvent = true;
} }

View File

@@ -237,7 +237,7 @@ ol.interaction.MouseWheelZoom.prototype.handleWheelZoom_ = function(map) {
} }
var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA; var maxDelta = ol.MOUSEWHEELZOOM_MAXDELTA;
var delta = ol.math.clamp(this.delta_, -maxDelta, 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.duration_);
this.mode_ = undefined; this.mode_ = undefined;
this.delta_ = 0; this.delta_ = 0;

View File

@@ -110,7 +110,7 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
var view = map.getView(); var view = map.getView();
var rotation = view.getRotation(); var rotation = view.getRotation();
map.render(); map.render();
ol.interaction.Interaction.rotateWithoutConstraints(map, view, ol.interaction.Interaction.rotateWithoutConstraints(view,
rotation + rotationDelta, this.anchor_); rotation + rotationDelta, this.anchor_);
} }
}; };
@@ -130,7 +130,7 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
if (this.rotating_) { if (this.rotating_) {
var rotation = view.getRotation(); var rotation = view.getRotation();
ol.interaction.Interaction.rotate( ol.interaction.Interaction.rotate(
map, view, rotation, this.anchor_, this.duration_); view, rotation, this.anchor_, this.duration_);
} }
return false; return false;
} else { } else {

View File

@@ -99,7 +99,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// scale, bypass the resolution constraint // scale, bypass the resolution constraint
map.render(); map.render();
ol.interaction.Interaction.zoomWithoutConstraints( 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 not to zoom out/in if user was pinching in/out.
// Direction is > 0 if pinching out, and < 0 if pinching in. // Direction is > 0 if pinching out, and < 0 if pinching in.
var direction = this.lastScaleDelta_ - 1; var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.zoom(map, view, resolution, ol.interaction.Interaction.zoom(view, resolution,
this.anchor_, this.duration_, direction); this.anchor_, this.duration_, direction);
} }
return false; return false;

View File

@@ -40,10 +40,10 @@ describe('ol.interaction.KeyboardPan', function() {
map.handleMapBrowserEvent(event); map.handleMapBrowserEvent(event);
event.originalEvent.keyCode = 39; // RIGHT event.originalEvent.keyCode = 39; // RIGHT
map.handleMapBrowserEvent(event); map.handleMapBrowserEvent(event);
expect(spy.getCall(0).args[2]).to.eql([0, -128]); expect(spy.getCall(0).args[1]).to.eql([0, -128]);
expect(spy.getCall(1).args[2]).to.eql([0, 128]); expect(spy.getCall(1).args[1]).to.eql([0, 128]);
expect(spy.getCall(2).args[2]).to.eql([-128, 0]); expect(spy.getCall(2).args[1]).to.eql([-128, 0]);
expect(spy.getCall(3).args[2]).to.eql([128, 0]); expect(spy.getCall(3).args[1]).to.eql([128, 0]);
ol.interaction.Interaction.pan.restore(); ol.interaction.Interaction.pan.restore();
}); });
}); });

View File

@@ -36,8 +36,8 @@ describe('ol.interaction.KeyboardZoom', function() {
map.handleMapBrowserEvent(event); map.handleMapBrowserEvent(event);
event.originalEvent.charCode = '-'.charCodeAt(0); event.originalEvent.charCode = '-'.charCodeAt(0);
map.handleMapBrowserEvent(event); map.handleMapBrowserEvent(event);
expect(spy.getCall(0).args[2]).to.eql(1); expect(spy.getCall(0).args[1]).to.eql(1);
expect(spy.getCall(1).args[2]).to.eql(-1); expect(spy.getCall(1).args[1]).to.eql(-1);
ol.interaction.Interaction.zoomByDelta.restore(); ol.interaction.Interaction.zoomByDelta.restore();
}); });
}); });

View File

@@ -106,8 +106,8 @@ describe('ol.interaction.MouseWheelZoom', function() {
it('works in DOM_DELTA_LINE mode (wheel)', function(done) { it('works in DOM_DELTA_LINE mode (wheel)', function(done) {
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta'); var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
map.once('postrender', function() { map.once('postrender', function() {
expect(spy.getCall(0).args[2]).to.be(-1); expect(spy.getCall(0).args[1]).to.be(-1);
expect(spy.getCall(0).args[3]).to.eql([0, 0]); expect(spy.getCall(0).args[2]).to.eql([0, 0]);
ol.interaction.Interaction.zoomByDelta.restore(); ol.interaction.Interaction.zoomByDelta.restore();
done(); done();
}); });
@@ -127,8 +127,8 @@ describe('ol.interaction.MouseWheelZoom', function() {
ol.has.SAFARI = true; ol.has.SAFARI = true;
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta'); var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
map.once('postrender', function() { map.once('postrender', function() {
expect(spy.getCall(0).args[2]).to.be(-1); expect(spy.getCall(0).args[1]).to.be(-1);
expect(spy.getCall(0).args[3]).to.eql([0, 0]); expect(spy.getCall(0).args[2]).to.eql([0, 0]);
ol.interaction.Interaction.zoomByDelta.restore(); ol.interaction.Interaction.zoomByDelta.restore();
ol.has.SAFARI = origHasSafari; ol.has.SAFARI = origHasSafari;
done(); done();
@@ -148,8 +148,8 @@ describe('ol.interaction.MouseWheelZoom', function() {
ol.has.SAFARI = false; ol.has.SAFARI = false;
var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta'); var spy = sinon.spy(ol.interaction.Interaction, 'zoomByDelta');
map.once('postrender', function() { map.once('postrender', function() {
expect(spy.getCall(0).args[2]).to.be(-1); expect(spy.getCall(0).args[1]).to.be(-1);
expect(spy.getCall(0).args[3]).to.eql([0, 0]); expect(spy.getCall(0).args[2]).to.eql([0, 0]);
ol.interaction.Interaction.zoomByDelta.restore(); ol.interaction.Interaction.zoomByDelta.restore();
ol.has.SAFARI = origHasSafari; ol.has.SAFARI = origHasSafari;
done(); done();