Skip to content

Commit

Permalink
Revert "Fix preview flickering on iOS devices (#542)" (#545)
Browse files Browse the repository at this point in the history
This reverts commit dcfdfc2.
  • Loading branch information
itanka9 authored Mar 11, 2021
1 parent 5dc5b6d commit 579c2e5
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/DGCustomization/src/DGMobileImprove.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ L.MobileTileLayer = L.TileLayer.extend({
var needPreview = this._needPreviewTile(wrapCoords);

var url = needPreview ? this._previewUrl : this._url;
var tile = this.createTile(wrapCoords, L.bind(needPreview ? this._previewReady : this._tileReady, this, coords), url);
var tile = this.createTile(wrapCoords, L.bind(this._tileReady, this, coords), url);

this._initTile(tile);

Expand All @@ -391,21 +391,6 @@ L.MobileTileLayer = L.TileLayer.extend({
});
},

_previewReady: function(coords, err, tile) {
if (!this._map) { return; }

var key = this._tileCoordsToKey(coords);

tile = this._tiles[key];
if (!tile) { return; }


tile.el.onload = L.bind(this._tileReady, this, coords, err, tile);
tile.el.onerror = L.bind(this._tileReady, this, coords, err, tile);
tile.el.src = this.getTileUrl(coords, this._url);
},


/**
* Убран fadeAnimated и класс leaflet-tile-loaded
*/
Expand All @@ -427,6 +412,23 @@ L.MobileTileLayer = L.TileLayer.extend({
tile = this._tiles[key];
if (!tile) { return; }

// Если у тайла уже есть оригинальная (не пожатая) картинка,
// то заменим превью на нее
if (tile.originalEl && tile.el.parentNode) {
tile.el.parentNode.replaceChild(tile.originalEl, tile.el);
tile.el = tile.originalEl;

tile.originalEl = null;
tile.preview = false;

// Если у тайла есть только превью, то добавим его на карту
// И начнем грузить оригинальный
} else if (tile.preview) {
tile.originalEl = this.createTile(this._wrapCoords(coords), L.bind(this._tileReady, this, coords), this._url);
this._initTile(tile.originalEl);
L.DomUtil.setPosition(tile.originalEl, this._getTilePos(coords));
}

tile.loaded = +new Date();
tile.active = true;
this._pruneTiles();
Expand Down

0 comments on commit 579c2e5

Please sign in to comment.