[fusion-commits] r2161 - sandbox/jxlib-3.0/widgets

svn_fusion at osgeo.org svn_fusion at osgeo.org
Thu May 20 13:47:35 EDT 2010


Author: madair
Date: 2010-05-20 13:47:35 -0400 (Thu, 20 May 2010)
New Revision: 2161

Modified:
   sandbox/jxlib-3.0/widgets/Legend.js
Log:
delay update of Legend for 500msec until pan/zoom stops


Modified: sandbox/jxlib-3.0/widgets/Legend.js
===================================================================
--- sandbox/jxlib-3.0/widgets/Legend.js	2010-05-20 17:45:38 UTC (rev 2160)
+++ sandbox/jxlib-3.0/widgets/Legend.js	2010-05-20 17:47:35 UTC (rev 2161)
@@ -224,6 +224,12 @@
     bIsDrawn: false,
 
     /**
+     * Property: updateDelay
+     * {Integer} number of milliseconds to delay the update of legend
+     */
+    updateDelay: 500,
+
+    /**
      * Property: targetFolder
      * {Jx.TreeFolder} The current TreeFolder that the mouse will interact with.
      */
@@ -477,9 +483,14 @@
         layer.legend.treeItem.check(layer.isVisible());
     },
 
+    updateTimer: null,
     update: function() {
         if (this.bIsDrawn) {
-            window.setTimeout(OpenLayers.Function.bind(this._update, this), 1);
+          if (this.updateTimer) {
+            window.clearTimeout(this.updateTimer);
+            this.updateTimer = null;
+          }
+          this.updateTimer = window.setTimeout(OpenLayers.Function.bind(this._update, this), this.updateDelay);
         }
     },
    
@@ -487,6 +498,7 @@
      * update the tree when the map scale changes
      */
     _update: function() {
+        this.updateTimer = null;
         var map = this.getMap();
         var currentScale = map.getScale();
         for (var i=0; i<map.layerRoot.groups.length; i++) {
@@ -706,6 +718,7 @@
     clearTreeItem: function(layer) {
         if (layer.legend.treeItem && layer.legend.treeItem.owner) {
             layer.legend.treeItem.owner.remove(layer.legend.treeItem);
+            layer.legend.treeItem.finalize();
             layer.legend.treeItem.destroy();
             layer.legend.treeItem = null;
         }



More information about the fusion-commits mailing list