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

@@ -1,11 +1,11 @@
goog.provide('ol.style.Icon');
goog.require('ol');
goog.require('ol.ImageState');
goog.require('ol.asserts');
goog.require('ol.color');
goog.require('ol.events');
goog.require('ol.events.EventType');
goog.require('ol.Image');
goog.require('ol.style.IconImage');
goog.require('ol.style.Image');
@@ -90,10 +90,10 @@ ol.style.Icon = function(opt_options) {
6); // A defined and non-empty `src` or `image` must be provided
/**
* @type {ol.Image.State}
* @type {ol.ImageState}
*/
var imageState = options.src !== undefined ?
ol.Image.State.IDLE : ol.Image.State.LOADED;
ol.ImageState.IDLE : ol.ImageState.LOADED;
/**
* @private
@@ -181,7 +181,7 @@ ol.inherits(ol.style.Icon, ol.style.Image);
ol.style.Icon.prototype.clone = function() {
var oldImage = this.getImage(1);
var newImage;
if (this.iconImage_.getImageState() === ol.Image.State.LOADED) {
if (this.iconImage_.getImageState() === ol.ImageState.LOADED) {
if (oldImage.tagName.toUpperCase() === 'IMG') {
newImage = /** @type {Image} */ (oldImage.cloneNode(true));
} else {

View File

@@ -5,7 +5,7 @@ goog.require('ol.dom');
goog.require('ol.events');
goog.require('ol.events.EventTarget');
goog.require('ol.events.EventType');
goog.require('ol.Image');
goog.require('ol.ImageState');
goog.require('ol.style');
@@ -15,7 +15,7 @@ goog.require('ol.style');
* @param {string|undefined} src Src.
* @param {ol.Size} size Size.
* @param {?string} crossOrigin Cross origin.
* @param {ol.Image.State} imageState Image state.
* @param {ol.ImageState} imageState Image state.
* @param {ol.Color} color Color.
* @extends {ol.events.EventTarget}
*/
@@ -62,7 +62,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
/**
* @private
* @type {ol.Image.State}
* @type {ol.ImageState}
*/
this.imageState_ = imageState;
@@ -83,7 +83,7 @@ ol.style.IconImage = function(image, src, size, crossOrigin, imageState,
* @type {boolean}
*/
this.tainting_ = false;
if (this.imageState_ == ol.Image.State.LOADED) {
if (this.imageState_ == ol.ImageState.LOADED) {
this.determineTainting_();
}
@@ -96,7 +96,7 @@ ol.inherits(ol.style.IconImage, ol.events.EventTarget);
* @param {string} src Src.
* @param {ol.Size} size Size.
* @param {?string} crossOrigin Cross origin.
* @param {ol.Image.State} imageState Image state.
* @param {ol.ImageState} imageState Image state.
* @param {ol.Color} color Color.
* @return {ol.style.IconImage} Icon image.
*/
@@ -139,7 +139,7 @@ ol.style.IconImage.prototype.dispatchChangeEvent_ = function() {
* @private
*/
ol.style.IconImage.prototype.handleImageError_ = function() {
this.imageState_ = ol.Image.State.ERROR;
this.imageState_ = ol.ImageState.ERROR;
this.unlistenImage_();
this.dispatchChangeEvent_();
};
@@ -149,7 +149,7 @@ ol.style.IconImage.prototype.handleImageError_ = function() {
* @private
*/
ol.style.IconImage.prototype.handleImageLoad_ = function() {
this.imageState_ = ol.Image.State.LOADED;
this.imageState_ = ol.ImageState.LOADED;
if (this.size_) {
this.image_.width = this.size_[0];
this.image_.height = this.size_[1];
@@ -172,7 +172,7 @@ ol.style.IconImage.prototype.getImage = function(pixelRatio) {
/**
* @return {ol.Image.State} Image state.
* @return {ol.ImageState} Image state.
*/
ol.style.IconImage.prototype.getImageState = function() {
return this.imageState_;
@@ -219,12 +219,12 @@ ol.style.IconImage.prototype.getSrc = function() {
* Load not yet loaded URI.
*/
ol.style.IconImage.prototype.load = function() {
if (this.imageState_ == ol.Image.State.IDLE) {
if (this.imageState_ == ol.ImageState.IDLE) {
ol.DEBUG && console.assert(this.src_ !== undefined,
'this.src_ must not be undefined');
ol.DEBUG && console.assert(!this.imageListenerKeys_,
'no listener keys existing');
this.imageState_ = ol.Image.State.LOADING;
this.imageState_ = ol.ImageState.LOADING;
this.imageListenerKeys_ = [
ol.events.listenOnce(this.image_, ol.events.EventType.ERROR,
this.handleImageError_, this),

View File

@@ -124,7 +124,7 @@ ol.style.Image.prototype.getHitDetectionImage = function(pixelRatio) {};
/**
* @abstract
* @return {ol.Image.State} Image state.
* @return {ol.ImageState} Image state.
*/
ol.style.Image.prototype.getImageState = function() {};

View File

@@ -4,7 +4,7 @@ goog.require('ol');
goog.require('ol.colorlike');
goog.require('ol.dom');
goog.require('ol.has');
goog.require('ol.Image');
goog.require('ol.ImageState');
goog.require('ol.render.canvas');
goog.require('ol.style.Image');
@@ -234,7 +234,7 @@ ol.style.RegularShape.prototype.getHitDetectionImageSize = function() {
* @inheritDoc
*/
ol.style.RegularShape.prototype.getImageState = function() {
return ol.Image.State.LOADED;
return ol.ImageState.LOADED;
};