[OpenLayers-Commits] r4741 - sandbox/pagameba/transition/lib/OpenLayers/Tile

commits at openlayers.org commits at openlayers.org
Mon Oct 1 16:32:55 EDT 2007


Author: pagameba
Date: 2007-10-01 16:32:54 -0400 (Mon, 01 Oct 2007)
New Revision: 4741

Modified:
   sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js
Log:
first cut at a resize transition effect that resizes the existing tile image in the backBuffer based on the ratio of the old resolution to the new resolution

Modified: sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js
===================================================================
--- sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js	2007-10-01 20:12:08 UTC (rev 4740)
+++ sandbox/pagameba/transition/lib/OpenLayers/Tile/Image.js	2007-10-01 20:32:54 UTC (rev 4741)
@@ -276,15 +276,38 @@
         }
     },
     
+    /**
+     * 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() {
         var ratio = 1;
         if (this.backBufferTile.resolution) {
-            ratio = this.layer.getResolution() / this.backBufferTile.resolution;            
+            ratio = this.backBufferTile.resolution / this.layer.getResolution() ;
         }
+        console.log('ratio is ' + ratio);
         switch (this.layer.transitionEffect) {
             case "resize": 
+                if (this.backBufferTile && this.backBufferTile.imgDiv) {
+                    var ul = 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(ul);
+                    OpenLayers.Util.modifyDOMElement(this.backBufferTile.frame, 
+                                                     null, px, size);   
+                    var imageSize = this.layer.getImageSize();
+                    imageSize = new OpenLayers.Size(imageSize.w * ratio, imageSize.h * ratio);
+                    
+                    OpenLayers.Util.modifyDOMElement(this.backBufferTile.imgDiv,
+                                                     null, null, imageSize) ;
+                
+                    OpenLayers.Element.show(this.backBufferTile.imgDiv);
+                }
                 break;
-            case "animate": 
+            case "animate":
                 break;
             default:
                 // default effect is just to leave the existing tile



More information about the Commits mailing list