remove back buffer immediately in applyBackBuffer if back buffer is schedule for removal

This commit is contained in:
Éric Lemoine
2012-01-04 08:20:11 +01:00
parent d4249960e3
commit 39f2ddccee

View File

@@ -459,6 +459,9 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* resolution - {Number} The resolution to transition to. * resolution - {Number} The resolution to transition to.
*/ */
applyBackBuffer: function(resolution) { applyBackBuffer: function(resolution) {
if(this.backBufferTimerId !== null) {
this.removeBackBuffer();
}
var backBuffer = this.backBuffer; var backBuffer = this.backBuffer;
if(!backBuffer) { if(!backBuffer) {
backBuffer = this.createBackBuffer(); backBuffer = this.createBackBuffer();
@@ -534,24 +537,17 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
* Remove back buffer from DOM. * Remove back buffer from DOM.
*/ */
removeBackBuffer: function() { removeBackBuffer: function() {
if(this.backBuffer && this.backBuffer.parentNode) { if(this.backBuffer) {
this.div.removeChild(this.backBuffer); this.div.removeChild(this.backBuffer);
this.backBuffer = null; this.backBuffer = null;
this.backBufferResolution = null; this.backBufferResolution = null;
if(this.backBufferTimerId !== null) {
window.clearTimeout(this.backBufferTimerId);
this.backBufferTimerId = null;
}
} }
}, },
/**
* Method: scheduleBackBufferRemoval
*/
scheduleBackBufferRemoval: function() {
if(this.backBufferTimerId !== null) {
window.clearTimeout(this.backBufferTimerId);
}
this.backBufferTimerId = window.setTimeout(
OpenLayers.Function.bind(this.removeBackBuffer, this), 2500);
},
/** /**
* Method: moveByPx * Method: moveByPx
* Move the layer based on pixel vector. * Move the layer based on pixel vector.
@@ -955,7 +951,10 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
if(this.backBuffer) { if(this.backBuffer) {
// the removal of the back buffer is delayed to prevent flash // the removal of the back buffer is delayed to prevent flash
// effects due to the animation of tile displaying // effects due to the animation of tile displaying
this.scheduleBackBufferRemoval(); this.backBufferTimerId = window.setTimeout(
OpenLayers.Function.bind(this.removeBackBuffer, this),
2500
);
} }
} }
}; };