From 7d0d11fba395d22cbae77585547145c4558b5718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Junod?= Date: Tue, 27 Nov 2007 10:17:54 +0000 Subject: [PATCH] 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 --- lib/OpenLayers/Tile/Image.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/OpenLayers/Tile/Image.js b/lib/OpenLayers/Tile/Image.js index a56791ded1..5d90e0ec0d 100644 --- a/lib/OpenLayers/Tile/Image.js +++ b/lib/OpenLayers/Tile/Image.js @@ -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"; }