[ol.Tile] as an isLoading method

This commit is contained in:
Éric Lemoine
2012-06-22 10:51:30 +02:00
parent f25b3aa350
commit ad2c3e15e3
2 changed files with 20 additions and 0 deletions

View File

@@ -100,6 +100,7 @@ ol.Tile.prototype.getImg = function() {
* @param {goog.events.BrowserEvent} evt Event.
*/
ol.Tile.prototype.handleImageLoad = function(evt) {
this.loading_ = false;
this.loaded_ = true;
this.events_.triggerEvent('load');
};
@@ -109,6 +110,7 @@ ol.Tile.prototype.handleImageLoad = function(evt) {
* @param {goog.events.BrowserEvent} evt Event.
*/
ol.Tile.prototype.handleImageError = function(evt) {
this.loading_ = false;
this.events_.triggerEvent('error');
};
@@ -120,6 +122,14 @@ ol.Tile.prototype.isLoaded = function() {
return this.loaded_;
};
/**
* Is the tile being loaded?
* @return {boolean}
*/
ol.Tile.prototype.isLoading = function() {
return this.loading_;
};
/**
*
*/

View File

@@ -42,6 +42,11 @@ describe("ol.Tile", function() {
tile.handleImageLoad();
expect(tile.isLoaded()).toBeTruthy();
});
it("unsets the loading flag", function() {
tile.loading_ = true;
tile.handleImageLoad();
expect(tile.isLoading()).toBeFalsy();
});
});
describe("handle image error", function() {
@@ -56,5 +61,10 @@ describe("ol.Tile", function() {
tile.handleImageError();
expect(spy).toHaveBeenCalled();
});
it("unsets the loading flag", function() {
tile.loading_ = true;
tile.handleImageError();
expect(tile.isLoading()).toBeFalsy();
});
});
});