Re #933. Apply transition effect patch to trunk, many thanks to Erik, Tim and Chris for support. r=crschmidt, tschaub.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@6452 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -146,6 +146,15 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
this.events.triggerEvent("loadstart");
|
||||
}
|
||||
|
||||
return this.renderTile();
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: renderTile
|
||||
* Internal function to actually initialize the image tile,
|
||||
* position it correctly, and set its url.
|
||||
*/
|
||||
renderTile: function() {
|
||||
if (this.imgDiv == null) {
|
||||
this.initImgDiv();
|
||||
}
|
||||
@@ -162,9 +171,9 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
OpenLayers.Util.modifyAlphaImageDiv(this.imgDiv,
|
||||
null, null, imageSize, this.url);
|
||||
} else {
|
||||
this.imgDiv.src = this.url;
|
||||
OpenLayers.Util.modifyDOMElement(this.imgDiv,
|
||||
null, null, imageSize) ;
|
||||
this.imgDiv.src = this.url;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
@@ -176,7 +185,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
*/
|
||||
clear: function() {
|
||||
if(this.imgDiv) {
|
||||
this.imgDiv.style.display = "none";
|
||||
this.hide();
|
||||
if (OpenLayers.Tile.Image.useBlankTile) {
|
||||
this.imgDiv.src = OpenLayers.Util.getImagesLocation() + "blank.gif";
|
||||
}
|
||||
@@ -223,6 +232,7 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
OpenLayers.Event.observe( this.imgDiv, "load",
|
||||
OpenLayers.Function.bind(this.checkImgURL, this) );
|
||||
*/
|
||||
this.frame.style.zIndex = this.isBackBuffer ? 0 : 1;
|
||||
this.frame.appendChild(this.imgDiv);
|
||||
this.layer.div.appendChild(this.frame);
|
||||
|
||||
@@ -300,11 +310,103 @@ OpenLayers.Tile.Image = OpenLayers.Class(OpenLayers.Tile, {
|
||||
if (this.layer) {
|
||||
var loaded = this.layerAlphaHack ? this.imgDiv.firstChild.src : this.imgDiv.src;
|
||||
if (!OpenLayers.Util.isEquivalentUrl(loaded, this.url)) {
|
||||
this.imgDiv.style.display = "none";
|
||||
this.hide();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: startTransition
|
||||
* This method is invoked on tiles that are backBuffers for tiles in the
|
||||
* grid. The grid tile is about to be cleared and a new tile source
|
||||
* loaded. This is where the transition effect needs to be started
|
||||
* to provide visual continuity.
|
||||
*/
|
||||
startTransition: function() {
|
||||
// backBufferTile has to be valid and ready to use
|
||||
if (!this.backBufferTile || !this.backBufferTile.imgDiv) {
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate the ratio of change between the current resolution of the
|
||||
// backBufferTile and the layer. If several animations happen in a
|
||||
// row, then the backBufferTile will scale itself appropriately for
|
||||
// each request.
|
||||
var ratio = 1;
|
||||
if (this.backBufferTile.resolution) {
|
||||
ratio = this.backBufferTile.resolution / this.layer.getResolution();
|
||||
}
|
||||
|
||||
// if the ratio is not the same as it was last time (i.e. we are
|
||||
// zooming), then we need to adjust the backBuffer tile
|
||||
if (ratio != this.lastRatio) {
|
||||
if (this.layer.transitionEffect == 'resize') {
|
||||
// In this case, we can just immediately resize the
|
||||
// backBufferTile.
|
||||
var upperLeft = new OpenLayers.LonLat(
|
||||
this.backBufferTile.bounds.left,
|
||||
this.backBufferTile.bounds.top
|
||||
);
|
||||
var size = new OpenLayers.Size(
|
||||
this.backBufferTile.size.w * ratio,
|
||||
this.backBufferTile.size.h * ratio
|
||||
);
|
||||
|
||||
var px = this.layer.map.getLayerPxFromLonLat(upperLeft);
|
||||
OpenLayers.Util.modifyDOMElement(this.backBufferTile.frame,
|
||||
null, px, size);
|
||||
var imageSize = this.backBufferTile.imageSize;
|
||||
imageSize = new OpenLayers.Size(imageSize.w * ratio,
|
||||
imageSize.h * ratio);
|
||||
var imageOffset = this.backBufferTile.imageOffset;
|
||||
if(imageOffset) {
|
||||
imageOffset = new OpenLayers.Pixel(
|
||||
imageOffset.x * ratio, imageOffset.y * ratio
|
||||
);
|
||||
}
|
||||
|
||||
OpenLayers.Util.modifyDOMElement(
|
||||
this.backBufferTile.imgDiv, null, imageOffset, imageSize
|
||||
) ;
|
||||
|
||||
this.backBufferTile.show();
|
||||
}
|
||||
} else {
|
||||
// default effect is just to leave the existing tile
|
||||
// until the new one loads if this is a singleTile and
|
||||
// there was no change in resolution. Otherwise we
|
||||
// don't bother to show the backBufferTile at all
|
||||
if (this.layer.singleTile) {
|
||||
this.backBufferTile.show();
|
||||
} else {
|
||||
this.backBufferTile.hide();
|
||||
}
|
||||
}
|
||||
this.lastRatio = ratio;
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: show
|
||||
* Show the tile by showing its frame.
|
||||
*/
|
||||
show: function() {
|
||||
this.frame.style.display = '';
|
||||
// Force a reflow on gecko based browsers to actually show the element
|
||||
// before continuing execution.
|
||||
if (navigator.userAgent.toLowerCase().indexOf("gecko") != -1) {
|
||||
this.frame.scrollLeft = this.frame.scrollLeft;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Method: hide
|
||||
* Hide the tile by hiding its frame.
|
||||
*/
|
||||
hide: function() {
|
||||
this.frame.style.display = 'none';
|
||||
},
|
||||
|
||||
CLASS_NAME: "OpenLayers.Tile.Image"
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user