Merge pull request #179 from ahocevar/tile-queue
A tile queue that can be aborted. r=@elemoine,@fredj,@tonio
This commit is contained in:
+23
-8
@@ -25,6 +25,10 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
|
||||
/**
|
||||
* Supported event types:
|
||||
* - *beforedraw* Triggered before the tile is drawn. Used to defer
|
||||
* drawing to an animation queue. To defer drawing, listeners need
|
||||
* to return false, which will abort drawing. The queue handler needs
|
||||
* to call <draw>(true) to actually draw the tile.
|
||||
* - *loadstart* Triggered when tile loading starts.
|
||||
* - *loadend* Triggered when tile loading ends.
|
||||
* - *reload* Triggered when an already loading tile is reloaded.
|
||||
@@ -107,7 +111,7 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
* {Boolean} Is the tile loading?
|
||||
*/
|
||||
isLoading: false,
|
||||
|
||||
|
||||
/** TBD 3.0 -- remove 'url' from the list of parameters to the constructor.
|
||||
* there is no need for the base tile class to have a url.
|
||||
*
|
||||
@@ -180,15 +184,26 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
* it should actually be re-drawn. This is an example implementation
|
||||
* that can be overridden by subclasses. The minimum thing to do here
|
||||
* is to call <clear> and return the result from <shouldDraw>.
|
||||
*
|
||||
* Parameters:
|
||||
* deferred - {Boolean} When drawing was aborted by returning false from a
|
||||
* *beforedraw* listener, the queue manager needs to pass true, so the
|
||||
* tile will not be cleared and immediately be drawn. Otherwise, the
|
||||
* tile will be cleared and a *beforedraw* event will be fired.
|
||||
*
|
||||
* Returns:
|
||||
* {Boolean} Whether or not the tile should actually be drawn.
|
||||
*/
|
||||
draw: function() {
|
||||
//clear tile's contents and mark as not drawn
|
||||
this.clear();
|
||||
|
||||
return this.shouldDraw();
|
||||
draw: function(deferred) {
|
||||
if (!deferred) {
|
||||
//clear tile's contents and mark as not drawn
|
||||
this.clear();
|
||||
}
|
||||
var draw = this.shouldDraw();
|
||||
if (draw && !deferred) {
|
||||
draw = this.events.triggerEvent("beforedraw") !== false;
|
||||
}
|
||||
return draw;
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -259,10 +274,10 @@ OpenLayers.Tile = OpenLayers.Class({
|
||||
/**
|
||||
* Method: clear
|
||||
* Clear the tile of any bounds/position-related data so that it can
|
||||
* be reused in a new location. To be implemented by subclasses.
|
||||
* be reused in a new location.
|
||||
*/
|
||||
clear: function(draw) {
|
||||
// to be implemented by subclasses
|
||||
// to be extended by subclasses
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Tile"
|
||||
|
||||
Reference in New Issue
Block a user