Exposing the documentDrag property on the Navigation control. r=ahocevar (closes #39)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@9805 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -8,9 +8,7 @@
|
|||||||
var map, layer;
|
var map, layer;
|
||||||
function init(){
|
function init(){
|
||||||
map = new OpenLayers.Map( 'map', {controls: [
|
map = new OpenLayers.Map( 'map', {controls: [
|
||||||
new OpenLayers.Control.Navigation(
|
new OpenLayers.Control.Navigation({documentDrag: true}),
|
||||||
{dragPanOptions: {documentDrag: true}}
|
|
||||||
),
|
|
||||||
new OpenLayers.Control.PanZoom(),
|
new OpenLayers.Control.PanZoom(),
|
||||||
new OpenLayers.Control.ArgParser(),
|
new OpenLayers.Control.ArgParser(),
|
||||||
new OpenLayers.Control.Attribution()
|
new OpenLayers.Control.Attribution()
|
||||||
|
|||||||
@@ -36,6 +36,13 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
*/
|
*/
|
||||||
dragPanOptions: null,
|
dragPanOptions: null,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APIProperty: documentDrag
|
||||||
|
* {Boolean} Allow panning of the map by dragging outside map viewport.
|
||||||
|
* Default is false.
|
||||||
|
*/
|
||||||
|
documentDrag: false,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Property: zoomBox
|
* Property: zoomBox
|
||||||
* {<OpenLayers.Control.ZoomBox>}
|
* {<OpenLayers.Control.ZoomBox>}
|
||||||
@@ -158,7 +165,10 @@ OpenLayers.Control.Navigation = OpenLayers.Class(OpenLayers.Control, {
|
|||||||
this, clickCallbacks, clickOptions
|
this, clickCallbacks, clickOptions
|
||||||
);
|
);
|
||||||
this.dragPan = new OpenLayers.Control.DragPan(
|
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(
|
this.zoomBox = new OpenLayers.Control.ZoomBox(
|
||||||
{map: this.map, keyMask: this.zoomBoxKeyMask});
|
{map: this.map, keyMask: this.zoomBoxKeyMask});
|
||||||
|
|||||||
@@ -96,6 +96,33 @@
|
|||||||
t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated");
|
t.eq(nav.zoomWheelEnabled, true, "mouse wheel activated");
|
||||||
t.eq(wheel.active, true, "mouse wheel handler 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>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|||||||
Reference in New Issue
Block a user