run view reset before load, fix #2510
This commit is contained in:
parent
b5b2dc06dc
commit
1a7b12604b
@ -1,12 +1,32 @@
|
||||
|
||||
describe('TileLayer', function () {
|
||||
var tileUrl = '';
|
||||
var tileUrl = '',
|
||||
map;
|
||||
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
});
|
||||
|
||||
describe("#onAdd", function () {
|
||||
it('is called after viewreset on first map load', function () {
|
||||
var layer = L.tileLayer(tileUrl).addTo(map);
|
||||
|
||||
var onAdd = layer.onAdd,
|
||||
onAddSpy = sinon.spy();
|
||||
layer.onAdd = function () {
|
||||
onAdd.apply(this, arguments);
|
||||
onAddSpy();
|
||||
};
|
||||
|
||||
var onReset = sinon.spy();
|
||||
map.on('viewreset', onReset);
|
||||
map.setView([0, 0], 0);
|
||||
|
||||
expect(onReset.calledBefore(onAddSpy)).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe("#getMaxZoom, #getMinZoom", function () {
|
||||
var map;
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
});
|
||||
describe("when a tilelayer is added to a map with no other layers", function () {
|
||||
it("has the same zoomlevels as the tilelayer", function () {
|
||||
var maxZoom = 10,
|
||||
|
@ -499,12 +499,12 @@ L.Map = L.Evented.extend({
|
||||
var loading = !this._loaded;
|
||||
this._loaded = true;
|
||||
|
||||
this.fire('viewreset', {hard: !preserveMapOffset});
|
||||
|
||||
if (loading) {
|
||||
this.fire('load');
|
||||
}
|
||||
|
||||
this.fire('viewreset', {hard: !preserveMapOffset});
|
||||
|
||||
this.fire('move');
|
||||
|
||||
if (zoomChanged || afterZoomAnim) {
|
||||
|
Loading…
Reference in New Issue
Block a user