diff --git a/spec/suites/map/MapSpec.js b/spec/suites/map/MapSpec.js index 9d8bbd5b4f8..fd73ced21ca 100644 --- a/spec/suites/map/MapSpec.js +++ b/spec/suites/map/MapSpec.js @@ -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 () { diff --git a/src/map/Map.js b/src/map/Map.js index 3cf164d52bd..5343e75e450 100644 --- a/src/map/Map.js +++ b/src/map/Map.js @@ -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; }, @@ -1169,7 +1169,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; @@ -1180,7 +1180,7 @@ export var Map = Evented.extend({ var zoomChanged = this._zoom !== zoom; this - ._moveStart(zoomChanged, false) + ._moveStart(zoomChanged, noMoveStart) ._move(center, zoom) ._moveEnd(zoomChanged);