Changeset 6462
- Timestamp:
- 03/07/08 18:04:32 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Control/Navigation.js
r6418 r6462 38 38 39 39 /** 40 * APIProperty: zoomWheelEnabled 41 * {Boolean} Whether the mousewheel should zoom the map 42 */ 43 zoomWheelEnabled: true, 44 45 /** 40 46 * Constructor: OpenLayers.Control.Navigation 41 47 * Create a new navigation control … … 76 82 activate: function() { 77 83 this.dragPan.activate(); 78 this.handlers.wheel.activate(); 84 if (this.zoomWheelEnabled) { 85 this.handlers.wheel.activate(); 86 } 79 87 this.handlers.click.activate(); 80 88 this.zoomBox.activate(); … … 169 177 this.wheelChange(evt, -1); 170 178 }, 179 180 /** 181 * Method: disableZoomWheel 182 */ 183 184 disableZoomWheel : function() { 185 this.zoomWheelEnabled = false; 186 this.handlers.wheel.deactivate(); 187 }, 188 189 /** 190 * Method: enableZoomWheel 191 */ 192 193 enableZoomWheel : function() { 194 this.zoomWheelEnabled = true; 195 if (this.active) { 196 this.handlers.wheel.activate(); 197 } 198 }, 171 199 172 200 CLASS_NAME: "OpenLayers.Control.Navigation" trunk/openlayers/tests/Control/test_Navigation.html
r6167 r6462 70 70 } 71 71 72 function test_Control_Navigation_disableZoomWheel(t) { 73 t.plan(2); 74 var nav = new OpenLayers.Control.Navigation(); 75 var wheel = new OpenLayers.Handler.MouseWheel(nav, {}); 76 nav.handlers.wheel = wheel; 77 wheel.register = function() {}; 78 wheel.unregister = function() {}; 79 wheel.activate(); 80 nav.disableZoomWheel(); 81 t.eq(nav.zoomWheelEnabled, false, "mouse wheel deactivated"); 82 t.eq(wheel.active, false, "mouse wheel handler deactivated"); 83 } 84 85 function test_Control_Navigation_enableZoomWheel(t) { 86 t.plan(2); 87 var nav = new OpenLayers.Control.Navigation({zoomWheelEnabled: false}); 88 nav.active = true; 89 var wheel = new OpenLayers.Handler.MouseWheel(nav, {}); 90 wheel.register = function() {}; 91 wheel.unregister = function() {}; 92 nav.handlers.wheel = wheel; 93 nav.enableZoomWheel(); 94 t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated"); 95 t.eq(wheel.active, true, "mouse wheel handler activated"); 96 } 97 72 98 </script> 73 99 </head>
