From b19893c9bac26e0499106ce8ad9c7cd91e89d61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Thu, 27 Apr 2017 15:38:55 +0200 Subject: [PATCH] Add hook points to allow for a proper NoGap plugin (#5476) --- src/layer/tile/GridLayer.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/layer/tile/GridLayer.js b/src/layer/tile/GridLayer.js index 445baf40..3ce8f56b 100644 --- a/src/layer/tile/GridLayer.js +++ b/src/layer/tile/GridLayer.js @@ -322,7 +322,11 @@ export var GridLayer = Layer.extend({ if (fade < 1) { nextFrame = true; } else { - if (tile.active) { willPrune = true; } + if (tile.active) { + willPrune = true; + } else { + this._onOpaqueTile(tile); + } tile.active = true; } } @@ -335,6 +339,8 @@ export var GridLayer = Layer.extend({ } }, + _onOpaqueTile: Util.falseFn, + _initContainer: function () { if (this._container) { return; } @@ -358,9 +364,11 @@ export var GridLayer = Layer.extend({ for (var z in this._levels) { if (this._levels[z].el.children.length || z === zoom) { this._levels[z].el.style.zIndex = maxZoom - Math.abs(zoom - z); + this._onUpdateLevel(z); } else { DomUtil.remove(this._levels[z].el); this._removeTilesAtZoom(z); + this._onRemoveLevel(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 Util.falseFn(level.el.offsetWidth); + + this._onCreateLevel(level); } this._level = level; @@ -388,6 +398,12 @@ export var GridLayer = Layer.extend({ return level; }, + _onUpdateLevel: Util.falseFn, + + _onRemoveLevel: Util.falseFn, + + _onCreateLevel: Util.falseFn, + _pruneTiles: function () { if (!this._map) { return; @@ -442,6 +458,7 @@ export var GridLayer = Layer.extend({ _invalidateAll: function () { for (var z in this._levels) { DomUtil.remove(this._levels[z].el); + this._onRemoveLevel(z); delete this._levels[z]; } this._removeAllTiles();