Add hook points to allow for a proper NoGap plugin (#5476)

This commit is contained in:
Iván Sánchez Ortega 2017-04-27 15:38:55 +02:00 committed by GitHub
parent bd7cf8a265
commit b19893c9ba

View File

@ -322,7 +322,11 @@ export var GridLayer = Layer.extend({
if (fade < 1) { if (fade < 1) {
nextFrame = true; nextFrame = true;
} else { } else {
if (tile.active) { willPrune = true; } if (tile.active) {
willPrune = true;
} else {
this._onOpaqueTile(tile);
}
tile.active = true; tile.active = true;
} }
} }
@ -335,6 +339,8 @@ export var GridLayer = Layer.extend({
} }
}, },
_onOpaqueTile: Util.falseFn,
_initContainer: function () { _initContainer: function () {
if (this._container) { return; } if (this._container) { return; }
@ -358,9 +364,11 @@ export var GridLayer = Layer.extend({
for (var z in this._levels) { for (var z in this._levels) {
if (this._levels[z].el.children.length || z === zoom) { if (this._levels[z].el.children.length || z === zoom) {
this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z); this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z);
this._onUpdateLevel(z);
} else { } else {
DomUtil.remove(this._levels[z].el); DomUtil.remove(this._levels[z].el);
this._removeTilesAtZoom(z); this._removeTilesAtZoom(z);
this._onRemoveLevel(z);
delete this._levels[z]; delete this._levels[z];
} }
} }
@ -381,6 +389,8 @@ export var GridLayer = Layer.extend({
// force the browser to consider the newly added element for transition // force the browser to consider the newly added element for transition
Util.falseFn(level.el.offsetWidth); Util.falseFn(level.el.offsetWidth);
this._onCreateLevel(level);
} }
this._level = level; this._level = level;
@ -388,6 +398,12 @@ export var GridLayer = Layer.extend({
return level; return level;
}, },
_onUpdateLevel: Util.falseFn,
_onRemoveLevel: Util.falseFn,
_onCreateLevel: Util.falseFn,
_pruneTiles: function () { _pruneTiles: function () {
if (!this._map) { if (!this._map) {
return; return;
@ -442,6 +458,7 @@ export var GridLayer = Layer.extend({
_invalidateAll: function () { _invalidateAll: function () {
for (var z in this._levels) { for (var z in this._levels) {
DomUtil.remove(this._levels[z].el); DomUtil.remove(this._levels[z].el);
this._onRemoveLevel(z);
delete this._levels[z]; delete this._levels[z];
} }
this._removeAllTiles(); this._removeAllTiles();