[OpenLayers-Commits] r2293 - sandbox/emanuel/animatedZooming/lib/OpenLayers/Control

commits at openlayers.org commits at openlayers.org
Thu Mar 1 12:06:26 EST 2007


Author: emanuel
Date: 2007-03-01 12:06:20 -0500 (Thu, 01 Mar 2007)
New Revision: 2293

Modified:
   sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/KeyboardDefaults.js
Log:
standard zoomlevel animation with +/-key

Modified: sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/KeyboardDefaults.js
===================================================================
--- sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/KeyboardDefaults.js	2007-03-01 16:57:42 UTC (rev 2292)
+++ sandbox/emanuel/animatedZooming/lib/OpenLayers/Control/KeyboardDefaults.js	2007-03-01 17:06:20 UTC (rev 2293)
@@ -13,7 +13,7 @@
   OpenLayers.Class.inherit( OpenLayers.Control, {
 
     /** @type int */
-    slideFactor: 100,
+    slideFactor: 75,
 
     /**
      * @constructor
@@ -26,13 +26,9 @@
      * 
      */
     draw: function() {
-//keypress
         OpenLayers.Event.observe(document, 
                       'keypress', 
                       this.defaultKeyDown.bindAsEventListener(this));
-        OpenLayers.Event.observe(document, 
-                      'keyup', 
-                      this.defaultKeyUp.bindAsEventListener(this));
     },
     
     /**
@@ -41,16 +37,16 @@
     defaultKeyDown: function (evt) {
         switch(evt.keyCode) {
             case OpenLayers.Event.KEY_LEFT:
-                this.map.pan(-75, 0);
+                this.map.pan(-this.slideFactor, 0);
                 break;
             case OpenLayers.Event.KEY_RIGHT: 
-                this.map.pan(75, 0);
+                this.map.pan(this.slideFactor, 0);
                 break;
             case OpenLayers.Event.KEY_UP:
-                this.map.pan(0, -75);
+                this.map.pan(0, -this.slideFactor);
                 break;
             case OpenLayers.Event.KEY_DOWN:
-                this.map.pan(0, 75);
+                this.map.pan(0, this.slideFactor);
                 break;
             case 33: // Page Up  
                 var size = this.map.getSize();
@@ -71,50 +67,16 @@
         }
         switch(evt.charCode) { 
             case 43: // + 
-                // get and set some settings for zoom animation 
-                this.map.prepareZoomAnimation();
-                this.map.zoomlevel_scale += 0.2;
-                // run zoom animation -> scale tile(s)
-                this.map.runZoomAnimation();
+                this.map.zoomIn();
                 break; 
             case 45: // - 
-                // get and set some settings for zoom animation 
-                this.map.prepareZoomAnimation();
-                this.map.zoomlevel_scale -= 0.2;
-                // run zoom animation -> scale tile(s)
-                this.map.runZoomAnimation();
+                this.map.zoomOut();
                 break; 
         }     
     },
     
-    defaultKeyUp: function (evt) {
-        switch(evt.keyCode) {
-            case 107:
-                if((this.map.zoomlevel_scale-this.map.zoomlevel_startScale) < 1)
-                {
-                    //this.map.zoomlevel_scale = Math.ceil(this.map.zoomlevel_scale);
-                    //this.map.runZoomAnimation();
-                    this.map.zoomTo(this.map.zoomlevel_startScale+1);
-                }
-                //this.map.finishZoomAnimation(Math.round(this.map.zoomlevel_scale));
 
-            case 109:
-                if((this.map.zoomlevel_scale-this.map.zoomlevel_startScale) < 1)
-                {
-                    Math.floor(this.map.zoomlevel_scale);
-                    this.map.runZoomAnimation();
-                }
-                // finish zoom animation
-                this.map.finishZoomAnimation(Math.round(this.map.zoomlevel_scale));
-                break;
 
-        }
-
-
-
-    },
-
-
     /** @final @type String */
     CLASS_NAME: "OpenLayers.Control.KeyboardDefaults"
 });



More information about the Commits mailing list