No magic for loadend delay
This change reintroduces the removeBackBufferDelay, and documents exactly what it does and when it may be useful.
This commit is contained in:
@@ -189,6 +189,17 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
*/
|
||||
backBufferLonLat: null,
|
||||
|
||||
/**
|
||||
* APIProperty: removeBackBufferDelay
|
||||
* {Number} Delay in ms for removing the backbuffer when all tiles have
|
||||
* finished loading. Usually a value of 0 works fine. For slow mobile
|
||||
* devices, when using <singleTile> layers with big image sizes, a delay
|
||||
* of 40-50ms may help to avoid flickers after panning. Default is 0.
|
||||
* If set, the layer's loadend event will also be delayed when a
|
||||
* backbuffer needs to be removed.
|
||||
*/
|
||||
removeBackBufferDelay: 0,
|
||||
|
||||
/**
|
||||
* APIProperty: className
|
||||
* {String} Name of the class added to the layer div. If not set in the
|
||||
@@ -1098,17 +1109,15 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
});
|
||||
//if that was the last tile, then trigger a 'loadend' on the layer
|
||||
if (this.tileQueue.length === 0 && this.numLoadingTiles === 0) {
|
||||
// give the last tile time to render before firing loadend and
|
||||
// removing the backbuffer.
|
||||
var delay = this.tileSize.w * this.tileSize.h / 32768;
|
||||
var that = this;
|
||||
window.setTimeout(function() {
|
||||
that.loading = false;
|
||||
that.events.triggerEvent("loadend");
|
||||
if(that.backBuffer) {
|
||||
if (this.backBuffer) {
|
||||
var that = this;
|
||||
window.setTimeout(function() {
|
||||
that.onLoadEnd();
|
||||
that.removeBackBuffer();
|
||||
}
|
||||
}, delay);
|
||||
}, this.removeBackBufferDelay);
|
||||
} else {
|
||||
this.onLoadEnd();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1125,6 +1134,15 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: onLoadEnd
|
||||
* Sets the loading flag to false and triggers the loadend event.
|
||||
*/
|
||||
onLoadEnd: function() {
|
||||
this.loading = false;
|
||||
this.events.triggerEvent("loadend");
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: removeTileMonitoringHooks
|
||||
* This function takes a tile as input and removes the tile hooks
|
||||
|
||||
Reference in New Issue
Block a user