Files
aladin-lite/_canvas/js/Tile.js
2014-10-23 07:07:36 +00:00

49 lines
1.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/******************************************************************************
* Aladin HTML5 project
*
* File Tile
*
* Author: Thomas Boch[CDS]
*
*****************************************************************************/
Tile = (function() {
var Tile = function(img, url) {
this.img = img;
this.url = url;
};
// check whether the image corresponding to the tile is loaded and ready to be displayed
//
// source : http://www.sajithmr.me/javascript-check-an-image-is-loaded-or-not
Tile.isImageOk = function(img) {
if (img.allSkyTexture) {
return true;
}
if (!img.src) {
return false;
}
// During the onload event, IE correctly identifies any images that
// werent downloaded as not complete. Others should too. Gecko-based
// browsers act like NS4 in that they report this incorrectly.
if (!img.complete) {
return false;
}
// However, they do have two very useful properties: naturalWidth and
// naturalHeight. These give the true size of the image. If it failed
// to load, either of these should be zero.
if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
return false;
}
// No other way of checking: assume its ok.
return true;
};
return Tile;
})();