Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented missing logic for noMoveStart when using panTo function #6685

Merged
merged 3 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add test and apply suggestions from johnd0e
  • Loading branch information
Falke-Design committed Apr 15, 2022
commit b1af1527589bd1a73ec08463d92d76e0902888e7
15 changes: 15 additions & 0 deletions spec/suites/map/MapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,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
7 changes: 3 additions & 4 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, options.pan);
this._resetView(center, zoom, options.pan && options.pan.noMoveStart);

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

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

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

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

Expand Down