Cancel http requests for outdated tiles (#5615)

* Cancel http requets for outdated tiles

* Don't cancel requests on stock android (see #137)
This commit is contained in:
James Collins 2017-08-15 11:46:28 -04:00 committed by Per Liedman
parent c78e5583e0
commit 7730948cab
2 changed files with 11 additions and 0 deletions

View File

@ -37,6 +37,11 @@ export var android = userAgentContains('android');
// @property android23: Boolean; `true` for browsers running on Android 2 or Android 3.
export var android23 = userAgentContains('android 2') || userAgentContains('android 3');
/* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */
var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit
// @property androidStock: Boolean; `true` for the Android stock browser (i.e. not Chrome)
export var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window);
// @property opera: Boolean; `true` for the Opera browser
export var opera = !!window.opera;

6
src/layer/tile/GridLayer.js Normal file → Executable file
View File

@ -768,6 +768,12 @@ export var GridLayer = Layer.extend({
var tile = this._tiles[key];
if (!tile) { return; }
// Cancels any pending http requests associated with the tile
// unless we're on Android's stock browser,
// see https://github.com/Leaflet/Leaflet/issues/137
if (!Browser.androidStock) {
tile.el.setAttribute('src', Util.emptyImageUrl);
}
DomUtil.remove(tile.el);
delete this._tiles[key];