Correctly check if the alpha hack needs to be applied to the layer's div by testing

if the alpha option is set and by calling Util.alphaHack(). 
Thanks elemoine for the review (Closes #1130)


git-svn-id: http://svn.openlayers.org/trunk/openlayers@5284 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
Frédéric Junod
2007-11-27 10:17:54 +00:00
parent 38652a7686
commit 7d0d11fba3

View File

@@ -36,6 +36,13 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
*/
frame: null,
/**
* Property: layerAlphaHack
* {Boolean} True if the png alpha hack needs to be applied on the layer's div.
*/
layerAlphaHack: null,
/** TBD 3.0 - reorder the parameters to the init function to remove
* URL. the getUrl() function on the layer gets called on
* each draw(), so no need to specify it here.
@@ -58,6 +65,8 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
this.frame = document.createElement('div');
this.frame.style.overflow = 'hidden';
this.frame.style.position = 'absolute';
this.layerAlphaHack = this.layer.alpha && OpenLayers.Util.alphaHack();
},
/**
@@ -115,7 +124,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
null, this.position, this.size);
var imageSize = this.layer.getImageSize();
if (this.layer.alpha) {
if (this.layerAlphaHack) {
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
null, null, imageSize, this.url);
} else {
@@ -146,7 +155,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
var offset = this.layer.imageOffset;
var size = this.layer.getImageSize();
if (this.layer.alpha) {
if (this.layerAlphaHack) {
this.imgDiv = OpenLayers.Util.createAlphaImageDiv(null,
offset,
size,
@@ -230,7 +239,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
// Sometimes our image will load after it has already been removed
// from the map, in which case this check is not needed.
if (this.layer) {
var loaded = this.layer.alpha ? this.imgDiv.firstChild.src : this.imgDiv.src;
var loaded = this.layerAlphaHack ? this.imgDiv.firstChild.src : this.imgDiv.src;
if (!OpenLayers.Util.isEquivalentUrl(loaded, this.url)) {
this.imgDiv.style.display = "none";
}