Use transitionend listeners where available
In addition to relying on removeBackBufferDelay, we can remove the backbuffer earlier without flicker in an ontransitionend listener on the last loaded tile.
This commit is contained in:
@@ -300,6 +300,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
arguments);
|
||||
this.grid = [];
|
||||
this.tileQueue = [];
|
||||
this._removeBackBuffer = OpenLayers.Function.bind(this.removeBackBuffer, this);
|
||||
|
||||
if (this.removeBackBufferDelay === null) {
|
||||
this.removeBackBufferDelay = this.singleTile ? 0 : 2500;
|
||||
@@ -757,6 +758,12 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
* Remove back buffer from DOM.
|
||||
*/
|
||||
removeBackBuffer: function() {
|
||||
if (this._transitionElement) {
|
||||
OpenLayers.Event.stopObserving(this._transitionElement, 'transitionend', this._removeBackBuffer);
|
||||
OpenLayers.Event.stopObserving(this._transitionElement, 'webkitTransitionEnd', this._removeBackBuffer);
|
||||
OpenLayers.Event.stopObserving(this._transitionElement, 'otransitionend', this._removeBackBuffer);
|
||||
delete this._transitionElement;
|
||||
}
|
||||
if(this.backBuffer) {
|
||||
this.div.removeChild(this.backBuffer);
|
||||
this.backBuffer = null;
|
||||
@@ -1120,11 +1127,13 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
this.loading = false;
|
||||
this.events.triggerEvent("loadend");
|
||||
if(this.backBuffer) {
|
||||
// the removal of the back buffer is delayed to prevent flash
|
||||
// effects due to the animation of tile displaying
|
||||
this._transitionElement = tile.imgDiv;
|
||||
OpenLayers.Event.observe(this._transitionElement, 'transitionend', this._removeBackBuffer);
|
||||
OpenLayers.Event.observe(this._transitionElement, 'webkitTransitionEnd', this._removeBackBuffer);
|
||||
OpenLayers.Event.observe(this._transitionElement, 'otransitionend', this._removeBackBuffer);
|
||||
// the removal of the back buffer is delayed to prevent // flash effects due to the animation of tile displaying
|
||||
this.backBufferTimerId = window.setTimeout(
|
||||
OpenLayers.Function.bind(this.removeBackBuffer, this),
|
||||
this.removeBackBufferDelay
|
||||
this._removeBackBuffer, this.removeBackBufferDelay
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user