Add optional callback to map.flyTo
This commit is contained in:
parent
a92c8a3c21
commit
60df920452
@ -570,4 +570,24 @@ describe("Map", function () {
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#flyTo', function () {
|
||||
|
||||
it('move to requested center and zoom, and call callback once', function (done) {
|
||||
var spy = sinon.spy(),
|
||||
newCenter = new L.LatLng(10, 11),
|
||||
newZoom = 12,
|
||||
callback = function () {
|
||||
expect(map.getCenter()).to.eql(newCenter);
|
||||
expect(map.getZoom()).to.eql(newZoom);
|
||||
spy();
|
||||
expect(spy.calledOnce).to.be.ok();
|
||||
done();
|
||||
};
|
||||
map.setView([0, 0], 0);
|
||||
map.flyTo(newCenter, newZoom, callback);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
L.Map.include({
|
||||
flyTo: function (targetCenter, targetZoom) {
|
||||
flyTo: function (targetCenter, targetZoom, callback) {
|
||||
|
||||
this.stop();
|
||||
|
||||
@ -51,6 +51,9 @@ L.Map.include({
|
||||
|
||||
} else {
|
||||
this._resetView(targetCenter, targetZoom, true, true);
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user