[ol.Tile] as an isLoading method
This commit is contained in:
@@ -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_;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user