[OpenLayers-Commits] r9805 - in trunk/openlayers: examples lib/OpenLayers/Control tests/Control

commits-20090109 at openlayers.org commits-20090109 at openlayers.org
Wed Nov 18 00:42:17 EST 2009


Author: tschaub
Date: 2009-11-18 00:42:17 -0500 (Wed, 18 Nov 2009)
New Revision: 9805
URL: http://trac.openlayers.org/changeset/9805

Modified:
   trunk/openlayers/examples/document-drag.html
   trunk/openlayers/lib/OpenLayers/Control/Navigation.js
   trunk/openlayers/tests/Control/Navigation.html
Log:
Exposing the documentDrag property on the Navigation control.  r=ahocevar (closes #39)

Modified: trunk/openlayers/examples/document-drag.html
===================================================================
--- trunk/openlayers/examples/document-drag.html	2009-11-17 14:40:01 UTC (rev 9804)
+++ trunk/openlayers/examples/document-drag.html	2009-11-18 05:42:17 UTC (rev 9805)
@@ -8,9 +8,7 @@
         var map, layer;
         function init(){
             map = new OpenLayers.Map( 'map', {controls: [
-                new OpenLayers.Control.Navigation(
-                    {dragPanOptions: {documentDrag: true}}
-                ),
+                new OpenLayers.Control.Navigation({documentDrag: true}),
                 new OpenLayers.Control.PanZoom(),
                 new OpenLayers.Control.ArgParser(),
                 new OpenLayers.Control.Attribution()

Modified: trunk/openlayers/lib/OpenLayers/Control/Navigation.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/Navigation.js	2009-11-17 14:40:01 UTC (rev 9804)
+++ trunk/openlayers/lib/OpenLayers/Control/Navigation.js	2009-11-18 05:42:17 UTC (rev 9805)
@@ -36,6 +36,13 @@
      */
     dragPanOptions: null,
 
+    /**
+     * APIProperty: documentDrag
+     * {Boolean} Allow panning of the map by dragging outside map viewport.
+     *     Default is false.
+     */
+    documentDrag: false,
+
     /** 
      * Property: zoomBox
      * {<OpenLayers.Control.ZoomBox>}
@@ -158,7 +165,10 @@
             this, clickCallbacks, clickOptions
         );
         this.dragPan = new OpenLayers.Control.DragPan(
-            OpenLayers.Util.extend({map: this.map}, this.dragPanOptions)
+            OpenLayers.Util.extend({
+                map: this.map,
+                documentDrag: this.documentDrag
+            }, this.dragPanOptions)
         );
         this.zoomBox = new OpenLayers.Control.ZoomBox(
                     {map: this.map, keyMask: this.zoomBoxKeyMask});

Modified: trunk/openlayers/tests/Control/Navigation.html
===================================================================
--- trunk/openlayers/tests/Control/Navigation.html	2009-11-17 14:40:01 UTC (rev 9804)
+++ trunk/openlayers/tests/Control/Navigation.html	2009-11-18 05:42:17 UTC (rev 9805)
@@ -96,7 +96,34 @@
         t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated");
         t.eq(wheel.active, true, "mouse wheel handler activated");
     }
+    
+    function test_documentDrag(t) {
+        
+        t.plan(2);
 
+        /**
+         * These tests confirm that the documentDrag property is false by 
+         * default and is passed on to the DragPan control.  Tests of panning
+         * while dragging outside the viewport should go in the DragPan tests.
+         * Tests of the document events and appropriate callbacks from the 
+         * handler should go in the Drag handler tests.
+         */
+         
+         var nav = new OpenLayers.Control.Navigation();
+         t.eq(nav.documentDrag, false, "documentDrag false by default");
+         // nav.destroy(); // fails if called before draw
+         
+         var map = new OpenLayers.Map({
+             div: document.body,
+             controls: [new OpenLayers.Control.Navigation({documentDrag: true})]
+         });
+         nav = map.controls[0];
+
+         t.eq(nav.dragPan.documentDrag, true, "documentDrag set on the DragPan control");
+         map.destroy();
+         
+    }
+
   </script>
 </head>
 <body>



More information about the Commits mailing list