Skip to content

Commit

Permalink
Implemented missing logic for noMoveStart when using panTo function (#…
Browse files Browse the repository at this point in the history
…6685)

* Implemented missing logic for noMoveStart when using panTo function

* Add test and apply suggestions from johnd0e

Co-authored-by: Tobias Johansson <tobias_johansson@live.se>
Co-authored-by: Florian Bischof <design.falke@gmail.com>
  • Loading branch information
3 people authored Apr 22, 2022
1 parent 9e97c62 commit cd0dcdd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions spec/suites/map/MapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,21 @@ describe("Map", function () {
expect(map.panBy.callCount).to.eql(1);
expect(map.panBy.args[0][1].duration).to.eql(13);
});

it("prevents firing movestart noMoveStart", function (done) {
var movestartSpy = sinon.spy();
map.on("movestart", movestartSpy);
var moveendSpy = sinon.spy();
map.on("moveend", moveendSpy);

map.setView([51.505, -0.09], 13, {pan: {noMoveStart: true}});

setTimeout(function () {
expect(movestartSpy.notCalled).to.eql(true);
expect(moveendSpy.calledOnce).to.eql(true);
done();
}, 100);
});
});

describe("#getBounds", function () {
Expand Down
6 changes: 3 additions & 3 deletions src/map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export var Map = Evented.extend({
}

// animation didn't start, just reset the map view
this._resetView(center, zoom);
this._resetView(center, zoom, options.pan && options.pan.noMoveStart);

return this;
},
Expand Down Expand Up @@ -1173,7 +1173,7 @@ export var Map = Evented.extend({
// private methods that modify map state

// @section Map state change events
_resetView: function (center, zoom) {
_resetView: function (center, zoom, noMoveStart) {
DomUtil.setPosition(this._mapPane, new Point(0, 0));

var loading = !this._loaded;
Expand All @@ -1184,7 +1184,7 @@ export var Map = Evented.extend({

var zoomChanged = this._zoom !== zoom;
this
._moveStart(zoomChanged, false)
._moveStart(zoomChanged, noMoveStart)
._move(center, zoom)
._moveEnd(zoomChanged);

Expand Down

0 comments on commit cd0dcdd

Please sign in to comment.