Giving the last tile time to render

The loadend event of an image is fired before the image is rendered. For
standard 256x256 tiles, this does not matter. But for singleTile layers on
large screens, rendering time needs to be considered. So we add a delay
that depends on the tile size. TODO: make the denominator configurable.
This commit is contained in:
ahocevar
2012-12-13 10:05:38 +01:00
parent a02163f01d
commit 1764bbdd18

View File

@@ -1098,11 +1098,17 @@ 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) {
this.loading = false;
this.events.triggerEvent("loadend");
if(this.backBuffer) {
this.removeBackBuffer();
}
// 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) {
that.removeBackBuffer();
}
}, delay);
}
};