Dedicated module for image state enum

This commit is contained in:
Tim Schaub
2016-12-27 09:02:02 -07:00
parent 549503bd2e
commit 63a8a5a2cc
13 changed files with 79 additions and 77 deletions

View File

@@ -2,6 +2,7 @@ goog.provide('ol.Image');
goog.require('ol');
goog.require('ol.ImageBase');
goog.require('ol.ImageState');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.extent');
@@ -22,7 +23,7 @@ goog.require('ol.obj');
ol.Image = function(extent, resolution, pixelRatio, attributions, src,
crossOrigin, imageLoadFunction) {
ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.Image.State.IDLE,
ol.ImageBase.call(this, extent, resolution, pixelRatio, ol.ImageState.IDLE,
attributions);
/**
@@ -54,9 +55,9 @@ ol.Image = function(extent, resolution, pixelRatio, attributions, src,
/**
* @protected
* @type {ol.Image.State}
* @type {ol.ImageState}
*/
this.state = ol.Image.State.IDLE;
this.state = ol.ImageState.IDLE;
/**
* @private
@@ -99,7 +100,7 @@ ol.Image.prototype.getImage = function(opt_context) {
* @private
*/
ol.Image.prototype.handleImageError_ = function() {
this.state = ol.Image.State.ERROR;
this.state = ol.ImageState.ERROR;
this.unlistenImage_();
this.changed();
};
@@ -114,7 +115,7 @@ ol.Image.prototype.handleImageLoad_ = function() {
if (this.resolution === undefined) {
this.resolution = ol.extent.getHeight(this.extent) / this.image_.height;
}
this.state = ol.Image.State.LOADED;
this.state = ol.ImageState.LOADED;
this.unlistenImage_();
this.changed();
};
@@ -127,8 +128,8 @@ ol.Image.prototype.handleImageLoad_ = function() {
* @api
*/
ol.Image.prototype.load = function() {
if (this.state == ol.Image.State.IDLE || this.state == ol.Image.State.ERROR) {
this.state = ol.Image.State.LOADING;
if (this.state == ol.ImageState.IDLE || this.state == ol.ImageState.ERROR) {
this.state = ol.ImageState.LOADING;
this.changed();
ol.DEBUG && console.assert(!this.imageListenerKeys_,
'this.imageListenerKeys_ should be null');
@@ -160,14 +161,3 @@ ol.Image.prototype.unlistenImage_ = function() {
this.imageListenerKeys_.forEach(ol.events.unlistenByKey);
this.imageListenerKeys_ = null;
};
/**
* @enum {number}
*/
ol.Image.State = {
IDLE: 0,
LOADING: 1,
LOADED: 2,
ERROR: 3
};